Completed
Push — console-installer ( 67c42e...186d32 )
by Adam
89:28 queued 70:47
created
modules/Leads/views/view.showduplicates.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             $this->ss->assign('RETURN_MODULE', 'Emails');
155 155
             $this->ss->assign('RETURN_ACTION', 'EditView');
156 156
             if(isset($_REQUEST['start'])) {
157
-               $this->ss->assign('START', $_REQUEST['start']);
157
+                $this->ss->assign('START', $_REQUEST['start']);
158 158
             }
159 159
         }
160 160
         ////	END INBOUND EMAIL WORKFLOW
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         $template = 'modules/Leads/tpls/ShowDuplicates.tpl';
192 192
         if(file_exists('custom/' . $template))
193 193
         {
194
-           $template = 'custom/' . $template;
194
+            $template = 'custom/' . $template;
195 195
         }
196 196
 
197 197
         $saveLabel = string_format($app_strings['LBL_SAVE_OBJECT'], array($this->module));
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 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.
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
         global $current_language;
57 57
         global $mod_strings;
58 58
 
59
-        if(!isset($_SESSION['SHOW_DUPLICATES']))
59
+        if (!isset($_SESSION['SHOW_DUPLICATES']))
60 60
         {
61 61
             $GLOBALS['log']->error("Unauthorized access to this area.");
62 62
             sugar_die("Unauthorized access to this area.");
63 63
         }
64 64
 
65
-        parse_str($_SESSION['SHOW_DUPLICATES'],$_POST);
65
+        parse_str($_SESSION['SHOW_DUPLICATES'], $_POST);
66 66
         $post = array_map("securexss", $_POST);
67 67
         foreach ($post as $k => $v) {
68 68
             $_POST[$k] = $v;
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
         $duplicateLeads = array();
96 96
         $db = DBManagerFactory::getInstance();
97 97
         $result = $db->query($query);
98
-        $i=0;
99
-        while (($row=$db->fetchByAssoc($result)) != null) {
98
+        $i = 0;
99
+        while (($row = $db->fetchByAssoc($result)) != null) {
100 100
             $duplicateLeads[$i] = $row;
101 101
             $i++;
102 102
         }
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
         }
120 120
 
121 121
         // Bug 25311 - Add special handling for when the form specifies many-to-many relationships
122
-        if(!empty($_POST['Leadsrelate_to'])) {
122
+        if (!empty($_POST['Leadsrelate_to'])) {
123 123
             $input .= "<input type='hidden' name='relate_to' value='{$_POST['Leadsrelate_to']}'>\n";
124 124
         }
125 125
 
126
-        if(!empty($_POST['Leadsrelate_id'])) {
126
+        if (!empty($_POST['Leadsrelate_id'])) {
127 127
             $input .= "<input type='hidden' name='relate_id' value='{$_POST['Leadsrelate_id']}'>\n";
128 128
         }
129 129
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $input .= $emailAddress->getEmailAddressWidgetDuplicatesView($lead);
133 133
 
134 134
         $get = '';
135
-        if(!empty($_POST['return_module']))
135
+        if (!empty($_POST['return_module']))
136 136
         {
137 137
             $this->ss->assign('RETURN_MODULE', $_POST['return_module']);
138 138
         } else {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         }
141 141
 
142 142
         $get .= "&return_action=";
143
-        if(!empty($_POST['return_action']))
143
+        if (!empty($_POST['return_action']))
144 144
         {
145 145
             $this->ss->assign('RETURN_ACTION', $_POST['return_action']);
146 146
         } else {
@@ -149,38 +149,38 @@  discard block
 block discarded – undo
149 149
 
150 150
         ///////////////////////////////////////////////////////////////////////////////
151 151
         ////	INBOUND EMAIL WORKFLOW
152
-        if(isset($_REQUEST['inbound_email_id'])) {
152
+        if (isset($_REQUEST['inbound_email_id'])) {
153 153
             $this->ss->assign('INBOUND_EMAIL_ID', $_REQUEST['inbound_email_id']);
154 154
             $this->ss->assign('RETURN_MODULE', 'Emails');
155 155
             $this->ss->assign('RETURN_ACTION', 'EditView');
156
-            if(isset($_REQUEST['start'])) {
156
+            if (isset($_REQUEST['start'])) {
157 157
                $this->ss->assign('START', $_REQUEST['start']);
158 158
             }
159 159
         }
160 160
         ////	END INBOUND EMAIL WORKFLOW
161 161
         ///////////////////////////////////////////////////////////////////////////////
162
-        if(!empty($_POST['popup']))
162
+        if (!empty($_POST['popup']))
163 163
         {
164 164
             $input .= '<input type="hidden" name="popup" value="'.$_POST['popup'].'">';
165 165
         } else {
166 166
             $input .= '<input type="hidden" name="popup" value="false">';
167 167
         }
168 168
 
169
-        if(!empty($_POST['to_pdf']))
169
+        if (!empty($_POST['to_pdf']))
170 170
         {
171 171
             $input .= '<input type="hidden" name="to_pdf" value="'.$_POST['to_pdf'].'">';
172 172
         } else {
173 173
             $input .= '<input type="hidden" name="to_pdf" value="false">';
174 174
         }
175 175
 
176
-        if(!empty($_POST['create']))
176
+        if (!empty($_POST['create']))
177 177
         {
178 178
             $input .= '<input type="hidden" name="create" value="'.$_POST['create'].'">';
179 179
         } else {
180 180
             $input .= '<input type="hidden" name="create" value="false">';
181 181
         }
182 182
 
183
-        if(!empty($_POST['return_id']))
183
+        if (!empty($_POST['return_id']))
184 184
         {
185 185
             $this->ss->assign('RETURN_ID', $_POST['return_id']);
186 186
         }
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 
190 190
         //Load the appropriate template
191 191
         $template = 'modules/Leads/tpls/ShowDuplicates.tpl';
192
-        if(file_exists('custom/' . $template))
192
+        if (file_exists('custom/'.$template))
193 193
         {
194
-           $template = 'custom/' . $template;
194
+           $template = 'custom/'.$template;
195 195
         }
196 196
 
197 197
         $saveLabel = string_format($app_strings['LBL_SAVE_OBJECT'], array($this->module));
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 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.
@@ -85,7 +87,9 @@  discard block
 block discarded – undo
85 87
             $first = true;
86 88
             foreach ($duplicates as $duplicate_id)
87 89
             {
88
-                if (!$first) $query .= ' OR ';
90
+                if (!$first) {
91
+                    $query .= ' OR ';
92
+                }
89 93
                 $first = false;
90 94
                 $query .= "id='$duplicate_id' ";
91 95
             }
Please login to merge, or discard this patch.
modules/Leads/views/view.convertlead.php 3 patches
Braces   +63 added lines, -65 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.
@@ -179,8 +181,7 @@  discard block
 block discarded – undo
179 181
         if($sugar_config['lead_conv_activity_opt'] == 'move')
180 182
         {
181 183
         	$smarty->assign('convertModuleListOptions', get_select_options_with_id(array('None'=>$app_strings['LBL_NONE'], 'Contacts' => $app_list_strings["moduleListSingular"]['Contacts']), ''));	
182
-        }
183
-        else if($sugar_config['lead_conv_activity_opt'] == 'copy')
184
+        } else if($sugar_config['lead_conv_activity_opt'] == 'copy')
184 185
         {
185 186
         	$smarty->assign('convertModuleListOptions', get_select_options_with_id(array('Contacts' => $app_list_strings["moduleListSingular"]['Contacts']), ''));
186 187
         }
@@ -212,17 +213,14 @@  discard block
 block discarded – undo
212 213
 	                if ($module == "Accounts" && $field == 'name')
213 214
 	                {
214 215
 	                    $focus->name = $this->focus->account_name;
215
-	                }
216
-	                else if ($module == "Opportunities" && $field == 'amount')
216
+	                } else if ($module == "Opportunities" && $field == 'amount')
217 217
 	                {
218 218
 	                    $focus->amount = unformat_number($this->focus->opportunity_amount);
219
-	                } 
220
-                 	else if ($module == "Opportunities" && $field == 'name') {
219
+	                } else if ($module == "Opportunities" && $field == 'name') {
221 220
                  		if ($opportunityNameInLayout && !empty($this->focus->opportunity_name)){
222 221
                            $focus->name = $this->focus->opportunity_name;
223 222
                  		}
224
-                   	}
225
-	                else if ($field == "id")
223
+                   	} else if ($field == "id")
226 224
                     {
227 225
 						//If it is not a contact, don't copy the ID from the lead
228 226
                     	if ($module == "Contacts") {
@@ -232,25 +230,25 @@  discard block
 block discarded – undo
232 230
 	                {
233 231
 	                	//Special case where company and person have the same field with a different name
234 232
 	                	$focus->phone_office = $this->focus->phone_work;
235
-	                }
236
-					else if (strpos($field, "billing_address") !== false && $focus->field_defs[$field]["type"] == "varchar") /* Bug 42219 fix */         
233
+	                } else if (strpos($field, "billing_address") !== false && $focus->field_defs[$field]["type"] == "varchar") {
234
+					    /* Bug 42219 fix */         
237 235
 					{
238 236
 						$tmp_field = str_replace("billing_", "primary_", $field);
237
+					}
239 238
 						$focus->field_defs[$field]["type"] = "text";
240 239
                         if (isset($this->focus->$tmp_field)) {
241 240
 						    $focus->$field = $this->focus->$tmp_field;
242 241
                         }
243
-					 }
244
-
245
-					else if (strpos($field, "shipping_address") !== false && $focus->field_defs[$field]["type"] == "varchar") /* Bug 42219 fix */
242
+					 } else if (strpos($field, "shipping_address") !== false && $focus->field_defs[$field]["type"] == "varchar") {
243
+					    /* Bug 42219 fix */
246 244
 					{
247 245
 						$tmp_field = str_replace("shipping_", "primary_", $field);
246
+					}
248 247
 						if (isset($this->focus->$tmp_field)) {
249 248
                             $focus->$field = $this->focus->$tmp_field;
250 249
                         }
251 250
 						$focus->field_defs[$field]["type"] = "text";
252
-					}    					
253
-                    else if (isset($this->focus->$field))
251
+					} else if (isset($this->focus->$field))
254 252
                     {
255 253
                         $focus->$field = $this->focus->$field;
256 254
                     }
@@ -403,8 +401,7 @@  discard block
 block discarded – undo
403 401
                 unset($_REQUEST["convert_create_Contacts"]);
404 402
                 unset($_POST["convert_create_Contacts"]);
405 403
             }
406
-        }
407
-        elseif (!empty($_REQUEST["convert_create_Contacts"]) && $_REQUEST["convert_create_Contacts"] != "false" && !isset($_POST['ContinueContact'])) 
404
+        } elseif (!empty($_REQUEST["convert_create_Contacts"]) && $_REQUEST["convert_create_Contacts"] != "false" && !isset($_POST['ContinueContact'])) 
408 405
         {
409 406
             require_once('modules/Contacts/ContactFormBase.php');
410 407
             $contactForm = new ContactFormBase();
@@ -425,8 +422,7 @@  discard block
 block discarded – undo
425 422
             $_REQUEST['account_id'] = $_REQUEST['selectedAccount'];
426 423
             unset($_REQUEST["convert_create_Accounts"]);
427 424
             unset($_POST["convert_create_Accounts"]);
428
-        }
429
-        elseif (!empty($_REQUEST["convert_create_Accounts"]) && $_REQUEST["convert_create_Accounts"] != "false" && empty($_POST['ContinueAccount']))
425
+        } elseif (!empty($_REQUEST["convert_create_Accounts"]) && $_REQUEST["convert_create_Accounts"] != "false" && empty($_POST['ContinueAccount']))
430 426
         {
431 427
             require_once('modules/Accounts/AccountFormBase.php');
432 428
             $accountForm = new AccountFormBase();
@@ -445,8 +441,9 @@  discard block
 block discarded – undo
445 441
             {
446 442
                 //Save the new record
447 443
                 $bean = $beanList[$module];
448
-	            if (empty($beans[$module]))
449
-	            	$beans[$module] = new $bean();
444
+	            if (empty($beans[$module])) {
445
+	            	            	$beans[$module] = new $bean();
446
+	            }
450 447
 
451 448
             	$this->populateNewBean($module, $beans[$module], $beans['Contacts'], $lead);
452 449
                 // when creating a new contact, create the id for linking with other modules
@@ -536,8 +533,7 @@  discard block
 block discarded – undo
536 533
                     {
537 534
                         $id_field = $relObject->rhs_key;
538 535
                         $lead->$id_field = $bean->id;
539
-                    }
540
-                    else 
536
+                    } else 
541 537
                     {
542 538
                         $bean->$leadsRel->add($lead->id);
543 539
                     }
@@ -550,8 +546,7 @@  discard block
 block discarded – undo
550 546
                 {
551 547
                     $bean->account_id = $beans['Accounts']->id;
552 548
                     $bean->account_name = $beans['Accounts']->name;
553
-                }
554
-                else if (!empty($selects['Accounts']))
549
+                } else if (!empty($selects['Accounts']))
555 550
                 {
556 551
                     $bean->account_id = $selects['Accounts'];
557 552
                 }
@@ -591,8 +586,7 @@  discard block
 block discarded – undo
591 586
             $bean->load_relationship($meetingsRel);
592 587
             $bean->$meetingsRel->add($current_user->id);
593 588
             return $bean;
594
-        }
595
-        else
589
+        } else
596 590
         {
597 591
             return false;
598 592
         }
@@ -611,8 +605,7 @@  discard block
 block discarded – undo
611 605
                     <a href='index.php?module={$bean->module_dir}&action=DetailView&record={$bean->id}'>
612 606
                        {$bean->get_summary_text()}
613 607
                     </a></li>";
614
-            }
615
-            else {
608
+            } else {
616 609
                 global $app_list_strings;
617 610
                 if(!empty($app_list_strings['moduleListSingular'][$bean->module_dir])) {
618 611
                     $module_name = $app_list_strings['moduleListSingular'][$bean->module_dir];
@@ -652,7 +645,7 @@  discard block
 block discarded – undo
652 645
             $account_id = create_guid();
653 646
             if(!empty($beans['Accounts']->id)){
654 647
                 $account_id = $beans['Accounts']->id;
655
-            }else{
648
+            } else{
656 649
                 $beans['Accounts']->id = $account_id;
657 650
             }
658 651
             $accountParentInfo = array('id'=>$account_id,'type'=>'Accounts');
@@ -683,8 +676,7 @@  discard block
 block discarded – undo
683 676
 	                                        }
684 677
 	                                    }
685 678
 	                                }
686
-	                            }
687
-	                            else if ($sugar_config['lead_conv_activity_opt'] == 'move') {
679
+	                            } else if ($sugar_config['lead_conv_activity_opt'] == 'move') {
688 680
 	                                // if to move activities, should be only one module selected
689 681
 	                                if ($_POST['lead_conv_ac_op_sel'] == $module) {
690 682
 	                                    $this->moveActivity($activity, $bean);
@@ -749,7 +741,9 @@  discard block
 block discarded – undo
749 741
 	    $lead
750 742
 	    )
751 743
 	{
752
-		if (!$lead) return;
744
+		if (!$lead) {
745
+		    return;
746
+		}
753 747
 
754 748
 		global $beanList, $db;
755 749
 
@@ -855,7 +849,10 @@  discard block
 block discarded – undo
855 849
 			if(!isset($_REQUEST[$module . $field]) && isset($lead->$field) && $field != 'id')
856 850
 			{
857 851
 				$bean->$field = $lead->$field;
858
-				if($field == 'date_entered') $bean->$field = gmdate($GLOBALS['timedate']->get_db_date_time_format()); //bug 41030
852
+				if($field == 'date_entered') {
853
+				    $bean->$field = gmdate($GLOBALS['timedate']->get_db_date_time_format());
854
+				}
855
+				//bug 41030
859 856
 			}
860 857
 		}
861 858
         populateFromPost($module, $bean, true);
@@ -872,10 +869,11 @@  discard block
 block discarded – undo
872 869
 				$contact->$fieldDef['id_name'] = $bean->id ;
873 870
 				if ($fieldDef['id_name'] != $select) {
874 871
 					$rname = isset($fieldDef['rname']) ? $fieldDef['rname'] : "";
875
-					if (!empty($rname) && isset($bean->$rname))
876
-						$contact->$select = $bean->$rname;
877
-					else
878
-						$contact->$select = $bean->name;
872
+					if (!empty($rname) && isset($bean->$rname)) {
873
+											$contact->$select = $bean->$rname;
874
+					} else {
875
+											$contact->$select = $bean->name;
876
+					}
879 877
 				}
880 878
 			}
881 879
 		} else if ($module != "Contacts"){
@@ -911,30 +909,33 @@  discard block
 block discarded – undo
911 909
 				if(!isset($_REQUEST[$bean->module_dir . $field]) && strpos($field, "_address_") !== false)
912 910
 				{
913 911
 					$set = "primary";
914
-					if (strpos($field, "alt_") !== false || strpos($field, "shipping_") !== false)
915
-						$set = "alt";
912
+					if (strpos($field, "alt_") !== false || strpos($field, "shipping_") !== false) {
913
+											$set = "alt";
914
+					}
916 915
 					$type = "";
917 916
 
918
-					if(strpos($field, "_address_street_2") !== false)
919
-						$type = "_address_street_2";
920
-					else if(strpos($field, "_address_street_3") !== false)
921
-						$type = "_address_street_3";
922
-					else if(strpos($field, "_address_street_4") !== false)
923
-						$type = "";
924
-					else if(strpos($field, "_address_street") !== false)
925
-						$type = "_address_street";
926
-					else if(strpos($field, "_address_city") !== false)
927
-						$type = "_address_city";
928
-					else if(strpos($field, "_address_state") !== false)
929
-						$type = "_address_state";
930
-					else if(strpos($field, "_address_postalcode") !== false)
931
-						$type = "_address_postalcode";
932
-					else if(strpos($field, "_address_country") !== false)
933
-						$type = "_address_country";
917
+					if(strpos($field, "_address_street_2") !== false) {
918
+											$type = "_address_street_2";
919
+					} else if(strpos($field, "_address_street_3") !== false) {
920
+											$type = "_address_street_3";
921
+					} else if(strpos($field, "_address_street_4") !== false) {
922
+											$type = "";
923
+					} else if(strpos($field, "_address_street") !== false) {
924
+											$type = "_address_street";
925
+					} else if(strpos($field, "_address_city") !== false) {
926
+											$type = "_address_city";
927
+					} else if(strpos($field, "_address_state") !== false) {
928
+											$type = "_address_state";
929
+					} else if(strpos($field, "_address_postalcode") !== false) {
930
+											$type = "_address_postalcode";
931
+					} else if(strpos($field, "_address_country") !== false) {
932
+											$type = "_address_country";
933
+					}
934 934
 
935 935
 						$var = $set.$type;
936
-					if (isset($contact->$var))
937
-						$bean->$field = $contact->$var;
936
+					if (isset($contact->$var)) {
937
+											$bean->$field = $contact->$var;
938
+					}
938 939
 				}
939 940
 			}
940 941
 	}
@@ -956,12 +957,10 @@  discard block
 block discarded – undo
956 957
                 if (isset($dictionary[$from->object_name]['relationships']) && isset($dictionary[$from->object_name]['relationships'][$rel_name]))
957 958
                 {
958 959
                     $rel_def = $dictionary[$from->object_name]['relationships'][$rel_name];
959
-                }
960
-                else if (isset($dictionary[$to->object_name]['relationships']) && isset($dictionary[$to->object_name]['relationships'][$rel_name]))
960
+                } else if (isset($dictionary[$to->object_name]['relationships']) && isset($dictionary[$to->object_name]['relationships'][$rel_name]))
961 961
                 {
962 962
                     $rel_def = $dictionary[$to->object_name]['relationships'][$rel_name];
963
-                }
964
-                else if (isset($dictionary[$rel_name]) && isset($dictionary[$rel_name]['relationships'])
963
+                } else if (isset($dictionary[$rel_name]) && isset($dictionary[$rel_name]['relationships'])
965 964
                         && isset($dictionary[$rel_name]['relationships'][$rel_name]))
966 965
                 {
967 966
                 	$rel_def = $dictionary[$rel_name]['relationships'][$rel_name];
@@ -970,8 +969,7 @@  discard block
 block discarded – undo
970 969
                     if ($rel_def['lhs_module'] == $from->module_dir && $rel_def['rhs_module'] == $to->module_dir )
971 970
                     {
972 971
                     	return $field;
973
-                    }
974
-                    else if ($rel_def['rhs_module'] == $from->module_dir && $rel_def['lhs_module'] == $to->module_dir )
972
+                    } else if ($rel_def['rhs_module'] == $from->module_dir && $rel_def['lhs_module'] == $to->module_dir )
975 973
                     {
976 974
                     	return $field;
977 975
                     }
Please login to merge, or discard this patch.
Indentation   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         )
53 53
     {
54 54
         parent::__construct($bean, $view_object_map);
55
-    	$this->medataDataFile = $this->fileName;
55
+        $this->medataDataFile = $this->fileName;
56 56
         if (file_exists("custom/$this->fileName"))
57 57
         {
58 58
             $this->medataDataFile = "custom/$this->fileName";
@@ -68,42 +68,42 @@  discard block
 block discarded – undo
68 68
     }
69 69
 
70 70
     /**
71
-	 * @see SugarView::display()
72
-	 */
73
-	public function display()
71
+     * @see SugarView::display()
72
+     */
73
+    public function display()
74 74
     {
75 75
         if (!empty($_REQUEST['handle']) && $_REQUEST['handle'] == 'save')
76 76
         {
77
-        	return $this->handleSave();
77
+            return $this->handleSave();
78 78
         }
79 79
 
80
-    	global $beanList;
80
+        global $beanList;
81 81
 
82
-    	// get the EditView defs to check if opportunity_name exists, for a check below for populating data
83
-    	$opportunityNameInLayout = false;
84
-    	$editviewFile = 'modules/Leads/metadata/editviewdefs.php';
82
+        // get the EditView defs to check if opportunity_name exists, for a check below for populating data
83
+        $opportunityNameInLayout = false;
84
+        $editviewFile = 'modules/Leads/metadata/editviewdefs.php';
85 85
         $this->medataDataFile = $editviewFile;
86 86
         if (file_exists("custom/{$editviewFile}"))
87 87
         {
88 88
             $this->medataDataFile = "custom/{$editviewFile}";
89 89
         }
90
-    	include($this->medataDataFile);
91
-    	foreach($viewdefs['Leads']['EditView']['panels'] as $panel_index => $section){
92
-    	    foreach($section as $row_array){
93
-    	        foreach($row_array as $cell){
94
-        	        if(isset($cell['name']) && $cell['name'] == 'opportunity_name'){
95
-        	            $opportunityNameInLayout = true;
96
-        	        }
97
-    	        }
98
-    	    }
99
-    	}
90
+        include($this->medataDataFile);
91
+        foreach($viewdefs['Leads']['EditView']['panels'] as $panel_index => $section){
92
+            foreach($section as $row_array){
93
+                foreach($row_array as $cell){
94
+                    if(isset($cell['name']) && $cell['name'] == 'opportunity_name'){
95
+                        $opportunityNameInLayout = true;
96
+                    }
97
+                }
98
+            }
99
+        }
100 100
 
101 101
         $this->medataDataFile = $this->fileName;
102 102
         if (file_exists("custom/$this->fileName"))
103 103
         {
104 104
             $this->medataDataFile = "custom/$this->fileName";
105 105
         }
106
-    	$this->loadDefs();
106
+        $this->loadDefs();
107 107
         $this->getRecord();
108 108
         $this->checkForDuplicates($this->focus);
109 109
         $smarty = new Sugar_Smarty();
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
         $smarty->assign("module", "Leads");
166 166
         $smarty->assign("view", "convertlead");
167 167
         $smarty->assign("bean", $this->focus);
168
-		$smarty->assign("record_id", $this->focus->id);
168
+        $smarty->assign("record_id", $this->focus->id);
169 169
         global $mod_strings;
170 170
         $smarty->assign('MOD', $mod_strings);
171 171
         $smarty->display("modules/Leads/tpls/ConvertLeadHeader.tpl");
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
         //Switch up list depending on copy or move
179 179
         if($sugar_config['lead_conv_activity_opt'] == 'move')
180 180
         {
181
-        	$smarty->assign('convertModuleListOptions', get_select_options_with_id(array('None'=>$app_strings['LBL_NONE'], 'Contacts' => $app_list_strings["moduleListSingular"]['Contacts']), ''));	
181
+            $smarty->assign('convertModuleListOptions', get_select_options_with_id(array('None'=>$app_strings['LBL_NONE'], 'Contacts' => $app_list_strings["moduleListSingular"]['Contacts']), ''));	
182 182
         }
183 183
         else if($sugar_config['lead_conv_activity_opt'] == 'copy')
184 184
         {
185
-        	$smarty->assign('convertModuleListOptions', get_select_options_with_id(array('Contacts' => $app_list_strings["moduleListSingular"]['Contacts']), ''));
185
+            $smarty->assign('convertModuleListOptions', get_select_options_with_id(array('Contacts' => $app_list_strings["moduleListSingular"]['Contacts']), ''));
186 186
         }
187 187
         
188 188
         
@@ -207,49 +207,49 @@  discard block
 block discarded – undo
207 207
             $focus->fill_in_additional_detail_fields();
208 208
             foreach($focus->field_defs as $field => $def)
209 209
             {
210
-            	if(isset($vdef[$ev->view]['copyData']) && $vdef[$ev->view]['copyData'])
210
+                if(isset($vdef[$ev->view]['copyData']) && $vdef[$ev->view]['copyData'])
211 211
                 {
212
-	                if ($module == "Accounts" && $field == 'name')
213
-	                {
214
-	                    $focus->name = $this->focus->account_name;
215
-	                }
216
-	                else if ($module == "Opportunities" && $field == 'amount')
217
-	                {
218
-	                    $focus->amount = unformat_number($this->focus->opportunity_amount);
219
-	                } 
220
-                 	else if ($module == "Opportunities" && $field == 'name') {
221
-                 		if ($opportunityNameInLayout && !empty($this->focus->opportunity_name)){
222
-                           $focus->name = $this->focus->opportunity_name;
223
-                 		}
224
-                   	}
225
-	                else if ($field == "id")
212
+                    if ($module == "Accounts" && $field == 'name')
213
+                    {
214
+                        $focus->name = $this->focus->account_name;
215
+                    }
216
+                    else if ($module == "Opportunities" && $field == 'amount')
217
+                    {
218
+                        $focus->amount = unformat_number($this->focus->opportunity_amount);
219
+                    } 
220
+                        else if ($module == "Opportunities" && $field == 'name') {
221
+                            if ($opportunityNameInLayout && !empty($this->focus->opportunity_name)){
222
+                            $focus->name = $this->focus->opportunity_name;
223
+                            }
224
+                        }
225
+                    else if ($field == "id")
226 226
                     {
227
-						//If it is not a contact, don't copy the ID from the lead
228
-                    	if ($module == "Contacts") {
229
-                    	   $focus->$field = $this->focus->$field;
227
+                        //If it is not a contact, don't copy the ID from the lead
228
+                        if ($module == "Contacts") {
229
+                            $focus->$field = $this->focus->$field;
230 230
                         }
231 231
                     } else if (is_a($focus, "Company") && $field == 'phone_office')
232
-	                {
233
-	                	//Special case where company and person have the same field with a different name
234
-	                	$focus->phone_office = $this->focus->phone_work;
235
-	                }
236
-					else if (strpos($field, "billing_address") !== false && $focus->field_defs[$field]["type"] == "varchar") /* Bug 42219 fix */         
237
-					{
238
-						$tmp_field = str_replace("billing_", "primary_", $field);
239
-						$focus->field_defs[$field]["type"] = "text";
232
+                    {
233
+                        //Special case where company and person have the same field with a different name
234
+                        $focus->phone_office = $this->focus->phone_work;
235
+                    }
236
+                    else if (strpos($field, "billing_address") !== false && $focus->field_defs[$field]["type"] == "varchar") /* Bug 42219 fix */         
237
+                    {
238
+                        $tmp_field = str_replace("billing_", "primary_", $field);
239
+                        $focus->field_defs[$field]["type"] = "text";
240 240
                         if (isset($this->focus->$tmp_field)) {
241
-						    $focus->$field = $this->focus->$tmp_field;
241
+                            $focus->$field = $this->focus->$tmp_field;
242
+                        }
242 243
                         }
243
-					 }
244 244
 
245
-					else if (strpos($field, "shipping_address") !== false && $focus->field_defs[$field]["type"] == "varchar") /* Bug 42219 fix */
246
-					{
247
-						$tmp_field = str_replace("shipping_", "primary_", $field);
248
-						if (isset($this->focus->$tmp_field)) {
245
+                    else if (strpos($field, "shipping_address") !== false && $focus->field_defs[$field]["type"] == "varchar") /* Bug 42219 fix */
246
+                    {
247
+                        $tmp_field = str_replace("shipping_", "primary_", $field);
248
+                        if (isset($this->focus->$tmp_field)) {
249 249
                             $focus->$field = $this->focus->$tmp_field;
250 250
                         }
251
-						$focus->field_defs[$field]["type"] = "text";
252
-					}    					
251
+                        $focus->field_defs[$field]["type"] = "text";
252
+                    }    					
253 253
                     else if (isset($this->focus->$field))
254 254
                     {
255 255
                         $focus->$field = $this->focus->$field;
@@ -272,18 +272,18 @@  discard block
 block discarded – undo
272 272
 
273 273
     protected function getRecord()
274 274
     {
275
-    	$this->focus = new Lead();
276
-    	if (isset($_REQUEST['record']))
277
-    	{
278
-    		$this->focus->retrieve($_REQUEST['record']);
279
-    	}
275
+        $this->focus = new Lead();
276
+        if (isset($_REQUEST['record']))
277
+        {
278
+            $this->focus->retrieve($_REQUEST['record']);
279
+        }
280 280
     }
281 281
 
282 282
     protected function loadDefs()
283 283
     {
284
-    	$viewdefs = array();
285
-    	include($this->medataDataFile);
286
-    	$this->defs = $viewdefs;
284
+        $viewdefs = array();
285
+        include($this->medataDataFile);
286
+        $this->defs = $viewdefs;
287 287
     }
288 288
 
289 289
     /**
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                     }
316 316
                     ";
317 317
         if ($validateSelect) {
318
-        	$jsOut  .= "
318
+            $jsOut  .= "
319 319
                     removeFromValidate('ConvertLead', '{$viewdef['select']}');";
320 320
         }
321 321
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
             YAHOO.util.Event.onDOMReady(SUGAR.convert.toggle$module);";
349 349
         } else if (isset($viewdef['default_action'])  && $viewdef['default_action'] == "create")
350 350
         {
351
-             $jsOut .= "\n            SUGAR.convert.{$module}Enabled = true;";
351
+                $jsOut .= "\n            SUGAR.convert.{$module}Enabled = true;";
352 352
         }
353 353
         $jsOut .= "
354 354
             YAHOO.util.Event.addListener('new$module', 'click', SUGAR.convert.toggle$module);
@@ -441,14 +441,14 @@  discard block
 block discarded – undo
441 441
         foreach ($this->defs as $module => $vdef)
442 442
         {
443 443
             //Create a new record if "create" was selected
444
-        	if (!empty($_REQUEST["convert_create_$module"]) && $_REQUEST["convert_create_$module"] != "false")
444
+            if (!empty($_REQUEST["convert_create_$module"]) && $_REQUEST["convert_create_$module"] != "false")
445 445
             {
446 446
                 //Save the new record
447 447
                 $bean = $beanList[$module];
448
-	            if (empty($beans[$module]))
449
-	            	$beans[$module] = new $bean();
448
+                if (empty($beans[$module]))
449
+                    $beans[$module] = new $bean();
450 450
 
451
-            	$this->populateNewBean($module, $beans[$module], $beans['Contacts'], $lead);
451
+                $this->populateNewBean($module, $beans[$module], $beans['Contacts'], $lead);
452 452
                 // when creating a new contact, create the id for linking with other modules
453 453
                 // and do not populate it with lead's old account_id
454 454
                 if ($module == 'Contacts')
@@ -602,8 +602,8 @@  discard block
 block discarded – undo
602 602
         $beans
603 603
         )
604 604
     {
605
-    	global $beanList;
606
-    	echo "<div><ul>";
605
+        global $beanList;
606
+        echo "<div><ul>";
607 607
         foreach($beans as $bean)
608 608
         {
609 609
             $beanName = $bean->object_name;
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
             }
631 631
         }
632 632
 
633
-    	echo "</ul></div>";
633
+        echo "</ul></div>";
634 634
     }
635 635
 
636 636
     protected function handleActivities(
@@ -638,12 +638,12 @@  discard block
 block discarded – undo
638 638
         $beans
639 639
         )
640 640
     {
641
-    	global $app_list_strings;
641
+        global $app_list_strings;
642 642
         global $sugar_config;
643 643
         global $app_strings;
644
-    	$parent_types = $app_list_strings['record_type_display'];
644
+        $parent_types = $app_list_strings['record_type_display'];
645 645
 
646
-    	$activities = $this->getActivitiesFromLead($lead);
646
+        $activities = $this->getActivitiesFromLead($lead);
647 647
 
648 648
         //if account is being created, we will specify the account as the parent bean
649 649
         $accountParentInfo = array();
@@ -659,42 +659,42 @@  discard block
 block discarded – undo
659 659
             $accountParentInfo = array('id'=>$account_id,'type'=>'Accounts');
660 660
         }
661 661
 
662
-    	foreach($beans as $module => $bean)
663
-    	{
664
-	    	if (isset($parent_types[$module]))
665
-	    	{
662
+        foreach($beans as $module => $bean)
663
+        {
664
+            if (isset($parent_types[$module]))
665
+            {
666 666
                 if (empty($bean->id))
667 667
                 {
668 668
                     $bean->id = create_guid();
669
-		            $bean->new_with_id = true;
669
+                    $bean->new_with_id = true;
670 670
                 }
671 671
                 if( isset($_POST['lead_conv_ac_op_sel']) && $_POST['lead_conv_ac_op_sel'] != 'None')
672 672
                 {
673
-	                foreach($activities as $activity)
674
-			    	{
675
-	                            if (!isset($sugar_config['lead_conv_activity_opt']) || $sugar_config['lead_conv_activity_opt'] == 'copy') {
676
-	                                if (isset($_POST['lead_conv_ac_op_sel'])) {
677
-	                                    //if the copy to module(s) are defined, copy only to those module(s)
678
-	                                    if (is_array($_POST['lead_conv_ac_op_sel'])) {
679
-	                                        foreach ($_POST['lead_conv_ac_op_sel'] as $mod) {
680
-	                                            if ($mod == $module) {
681
-	                                                $this->copyActivityAndRelateToBean($activity, $bean, $accountParentInfo);
682
-	                                                break;
683
-	                                            }
684
-	                                        }
685
-	                                    }
686
-	                                }
687
-	                            }
688
-	                            else if ($sugar_config['lead_conv_activity_opt'] == 'move') {
689
-	                                // if to move activities, should be only one module selected
690
-	                                if ($_POST['lead_conv_ac_op_sel'] == $module) {
691
-	                                    $this->moveActivity($activity, $bean);
692
-	                                }
693
-	                            }
694
-			    	}
673
+                    foreach($activities as $activity)
674
+                    {
675
+                                if (!isset($sugar_config['lead_conv_activity_opt']) || $sugar_config['lead_conv_activity_opt'] == 'copy') {
676
+                                    if (isset($_POST['lead_conv_ac_op_sel'])) {
677
+                                        //if the copy to module(s) are defined, copy only to those module(s)
678
+                                        if (is_array($_POST['lead_conv_ac_op_sel'])) {
679
+                                            foreach ($_POST['lead_conv_ac_op_sel'] as $mod) {
680
+                                                if ($mod == $module) {
681
+                                                    $this->copyActivityAndRelateToBean($activity, $bean, $accountParentInfo);
682
+                                                    break;
683
+                                                }
684
+                                            }
685
+                                        }
686
+                                    }
687
+                                }
688
+                                else if ($sugar_config['lead_conv_activity_opt'] == 'move') {
689
+                                    // if to move activities, should be only one module selected
690
+                                    if ($_POST['lead_conv_ac_op_sel'] == $module) {
691
+                                        $this->moveActivity($activity, $bean);
692
+                                    }
693
+                                }
694
+                    }
695 695
                 }
696
-	    	}
697
-    	}
696
+            }
697
+        }
698 698
     }
699 699
 
700 700
     /**
@@ -746,46 +746,46 @@  discard block
 block discarded – undo
746 746
      * @param Lead $lead Lead to get activities from
747 747
      * @return Array of Activity SugarBeans .
748 748
      */
749
-	protected function getActivitiesFromLead(
750
-	    $lead
751
-	    )
752
-	{
753
-		if (!$lead) return;
754
-
755
-		global $beanList, $db;
756
-
757
-		$activitesList = array("Calls", "Tasks", "Meetings", "Emails", "Notes");
758
-		$activities = array();
759
-
760
-		foreach($activitesList as $module)
761
-		{
762
-			$beanName = $beanList[$module];
763
-			$activity = new $beanName();
764
-			$query = "SELECT id FROM {$activity->table_name} WHERE parent_id = '{$lead->id}' AND parent_type = 'Leads' AND deleted = 0";
765
-			$result = $db->query($query,true);
749
+    protected function getActivitiesFromLead(
750
+        $lead
751
+        )
752
+    {
753
+        if (!$lead) return;
754
+
755
+        global $beanList, $db;
756
+
757
+        $activitesList = array("Calls", "Tasks", "Meetings", "Emails", "Notes");
758
+        $activities = array();
759
+
760
+        foreach($activitesList as $module)
761
+        {
762
+            $beanName = $beanList[$module];
763
+            $activity = new $beanName();
764
+            $query = "SELECT id FROM {$activity->table_name} WHERE parent_id = '{$lead->id}' AND parent_type = 'Leads' AND deleted = 0";
765
+            $result = $db->query($query,true);
766 766
             while($row = $db->fetchByAssoc($result))
767 767
             {
768
-            	$activity = new $beanName();
769
-				$activity->retrieve($row['id']);
770
-				$activity->fixUpFormatting();
771
-				$activities[] = $activity;
768
+                $activity = new $beanName();
769
+                $activity->retrieve($row['id']);
770
+                $activity->fixUpFormatting();
771
+                $activities[] = $activity;
772 772
             }
773
-		}
773
+        }
774 774
 
775
-		return $activities;
776
-	}
775
+        return $activities;
776
+    }
777 777
 
778
-	protected function copyActivityAndRelateToBean(
779
-	    $activity,
780
-	    $bean,
778
+    protected function copyActivityAndRelateToBean(
779
+        $activity,
780
+        $bean,
781 781
         $parentArr = array()
782
-	    )
783
-	{
784
-		global $beanList;
782
+        )
783
+    {
784
+        global $beanList;
785 785
 
786
-		$newActivity = clone $activity;
787
-		$newActivity->id = create_guid();
788
-		$newActivity->new_with_id = true;
786
+        $newActivity = clone $activity;
787
+        $newActivity->id = create_guid();
788
+        $newActivity->new_with_id = true;
789 789
 
790 790
         //set the parent id and type if it was passed in, otherwise use blank to wipe it out
791 791
         $parentID = '';
@@ -801,13 +801,13 @@  discard block
 block discarded – undo
801 801
 
802 802
         }
803 803
 
804
-		//Special case to prevent duplicated tasks from appearing under Contacts multiple times
805
-    	if ($newActivity->module_dir == "Tasks" && $bean->module_dir != "Contacts")
806
-    	{
804
+        //Special case to prevent duplicated tasks from appearing under Contacts multiple times
805
+        if ($newActivity->module_dir == "Tasks" && $bean->module_dir != "Contacts")
806
+        {
807 807
             $newActivity->contact_id = $newActivity->contact_name = "";
808
-    	}
808
+        }
809 809
 
810
-		if ($rel = $this->findRelationship($newActivity, $bean))
810
+        if ($rel = $this->findRelationship($newActivity, $bean))
811 811
         {
812 812
             if (isset($newActivity->$rel))
813 813
             {
@@ -828,14 +828,14 @@  discard block
 block discarded – undo
828 828
             $newActivity->parent_id =  $parentID;
829 829
             $newActivity->parent_type = $parentType;
830 830
 
831
-	        $newActivity->update_date_modified = false; //bug 41747
832
-	        $newActivity->save();
831
+            $newActivity->update_date_modified = false; //bug 41747
832
+            $newActivity->save();
833 833
             $newActivity->$rel->add($bean);
834 834
             if ($newActivity->module_dir == "Notes" && $newActivity->filename) {
835
-	        	UploadFile::duplicate_file($activity->id, $newActivity->id,  $newActivity->filename);
836
-	        }
837
-         }
838
-	}
835
+                UploadFile::duplicate_file($activity->id, $newActivity->id,  $newActivity->filename);
836
+            }
837
+            }
838
+    }
839 839
 
840 840
     /**
841 841
      * Populates the passed in Bean fron the contact and the $_REQUEST
@@ -843,103 +843,103 @@  discard block
 block discarded – undo
843 843
      * @param SugarBean $bean SugarBean to be populated.
844 844
      * @param Contact $contact Contact to relate the bean to.
845 845
      */
846
-	protected function populateNewBean(
847
-	    $module,
848
-	    $bean,
849
-	    $contact,
850
-	    $lead
851
-	    )
852
-	{
853
-		//Copy data from the contact to new bean
854
-		foreach($bean->field_defs as $field => $def)
855
-		{
856
-			if(!isset($_REQUEST[$module . $field]) && isset($lead->$field) && $field != 'id')
857
-			{
858
-				$bean->$field = $lead->$field;
859
-				if($field == 'date_entered') $bean->$field = gmdate($GLOBALS['timedate']->get_db_date_time_format()); //bug 41030
860
-			}
861
-		}
846
+    protected function populateNewBean(
847
+        $module,
848
+        $bean,
849
+        $contact,
850
+        $lead
851
+        )
852
+    {
853
+        //Copy data from the contact to new bean
854
+        foreach($bean->field_defs as $field => $def)
855
+        {
856
+            if(!isset($_REQUEST[$module . $field]) && isset($lead->$field) && $field != 'id')
857
+            {
858
+                $bean->$field = $lead->$field;
859
+                if($field == 'date_entered') $bean->$field = gmdate($GLOBALS['timedate']->get_db_date_time_format()); //bug 41030
860
+            }
861
+        }
862 862
         populateFromPost($module, $bean, true);
863
-		//Try to link to the new contact
864
-		$contactRel = "";
865
-		if (!empty($vdef['ConvertLead']['select']))
866
-		{
867
-			$select = $vdef['ConvertLead']['select'];
868
-			$fieldDef = $contact->field_defs[$select];
869
-			if (!empty($fieldDef['id_name']))
870
-			{
871
-				$bean->id = create_guid();
872
-				$bean->new_with_id = true;
863
+        //Try to link to the new contact
864
+        $contactRel = "";
865
+        if (!empty($vdef['ConvertLead']['select']))
866
+        {
867
+            $select = $vdef['ConvertLead']['select'];
868
+            $fieldDef = $contact->field_defs[$select];
869
+            if (!empty($fieldDef['id_name']))
870
+            {
871
+                $bean->id = create_guid();
872
+                $bean->new_with_id = true;
873 873
                 $idName = $fieldDef['id_name'];
874
-				$contact->$idName = $bean->id ;
875
-				if ($idName != $select) {
876
-					$rname = isset($fieldDef['rname']) ? $fieldDef['rname'] : "";
877
-					if (!empty($rname) && isset($bean->$rname))
878
-						$contact->$select = $bean->$rname;
879
-					else
880
-						$contact->$select = $bean->name;
881
-				}
882
-			}
883
-		} else if ($module != "Contacts"){
884
-			$contactRel = $this->findRelationship($contact, $bean);
885
-			if (!empty($contactRel))
886
-			{
887
-				$bean->id = create_guid();
888
-				$bean->new_with_id = true;
889
-				$contact->load_relationship ($contactRel) ;
890
-				$relObject = $contact->$contactRel->getRelationshipObject();
891
-				if ($relObject->relationship_type == "one-to-many" && $contact->$contactRel->_get_bean_position())
892
-				{
893
-					$id_field = $relObject->rhs_key;
894
-					$bean->$id_field = $contact->id;
895
-				} else {
896
-					$contact->$contactRel->add($bean);
897
-				}
898
-				//Set the parent of activites to the new Contact
899
-				if (isset($bean->field_defs['parent_id']) && isset($bean->field_defs['parent_type']))
900
-				{
901
-					$bean->parent_id = $contact->id;
902
-					$bean->parent_type = "Contacts";
903
-				}
904
-			}
905
-		}
906
-	}
907
-
908
-	protected function copyAddressFields($bean, $contact)
909
-	{
910
-	//Copy over address info from the contact to any beans with address not set
911
-	        foreach($bean->field_defs as $field => $def)
912
-			{
913
-				if(!isset($_REQUEST[$bean->module_dir . $field]) && strpos($field, "_address_") !== false)
914
-				{
915
-					$set = "primary";
916
-					if (strpos($field, "alt_") !== false || strpos($field, "shipping_") !== false)
917
-						$set = "alt";
918
-					$type = "";
919
-
920
-					if(strpos($field, "_address_street_2") !== false)
921
-						$type = "_address_street_2";
922
-					else if(strpos($field, "_address_street_3") !== false)
923
-						$type = "_address_street_3";
924
-					else if(strpos($field, "_address_street_4") !== false)
925
-						$type = "";
926
-					else if(strpos($field, "_address_street") !== false)
927
-						$type = "_address_street";
928
-					else if(strpos($field, "_address_city") !== false)
929
-						$type = "_address_city";
930
-					else if(strpos($field, "_address_state") !== false)
931
-						$type = "_address_state";
932
-					else if(strpos($field, "_address_postalcode") !== false)
933
-						$type = "_address_postalcode";
934
-					else if(strpos($field, "_address_country") !== false)
935
-						$type = "_address_country";
936
-
937
-						$var = $set.$type;
938
-					if (isset($contact->$var))
939
-						$bean->$field = $contact->$var;
940
-				}
941
-			}
942
-	}
874
+                $contact->$idName = $bean->id ;
875
+                if ($idName != $select) {
876
+                    $rname = isset($fieldDef['rname']) ? $fieldDef['rname'] : "";
877
+                    if (!empty($rname) && isset($bean->$rname))
878
+                        $contact->$select = $bean->$rname;
879
+                    else
880
+                        $contact->$select = $bean->name;
881
+                }
882
+            }
883
+        } else if ($module != "Contacts"){
884
+            $contactRel = $this->findRelationship($contact, $bean);
885
+            if (!empty($contactRel))
886
+            {
887
+                $bean->id = create_guid();
888
+                $bean->new_with_id = true;
889
+                $contact->load_relationship ($contactRel) ;
890
+                $relObject = $contact->$contactRel->getRelationshipObject();
891
+                if ($relObject->relationship_type == "one-to-many" && $contact->$contactRel->_get_bean_position())
892
+                {
893
+                    $id_field = $relObject->rhs_key;
894
+                    $bean->$id_field = $contact->id;
895
+                } else {
896
+                    $contact->$contactRel->add($bean);
897
+                }
898
+                //Set the parent of activites to the new Contact
899
+                if (isset($bean->field_defs['parent_id']) && isset($bean->field_defs['parent_type']))
900
+                {
901
+                    $bean->parent_id = $contact->id;
902
+                    $bean->parent_type = "Contacts";
903
+                }
904
+            }
905
+        }
906
+    }
907
+
908
+    protected function copyAddressFields($bean, $contact)
909
+    {
910
+    //Copy over address info from the contact to any beans with address not set
911
+            foreach($bean->field_defs as $field => $def)
912
+            {
913
+                if(!isset($_REQUEST[$bean->module_dir . $field]) && strpos($field, "_address_") !== false)
914
+                {
915
+                    $set = "primary";
916
+                    if (strpos($field, "alt_") !== false || strpos($field, "shipping_") !== false)
917
+                        $set = "alt";
918
+                    $type = "";
919
+
920
+                    if(strpos($field, "_address_street_2") !== false)
921
+                        $type = "_address_street_2";
922
+                    else if(strpos($field, "_address_street_3") !== false)
923
+                        $type = "_address_street_3";
924
+                    else if(strpos($field, "_address_street_4") !== false)
925
+                        $type = "";
926
+                    else if(strpos($field, "_address_street") !== false)
927
+                        $type = "_address_street";
928
+                    else if(strpos($field, "_address_city") !== false)
929
+                        $type = "_address_city";
930
+                    else if(strpos($field, "_address_state") !== false)
931
+                        $type = "_address_state";
932
+                    else if(strpos($field, "_address_postalcode") !== false)
933
+                        $type = "_address_postalcode";
934
+                    else if(strpos($field, "_address_country") !== false)
935
+                        $type = "_address_country";
936
+
937
+                        $var = $set.$type;
938
+                    if (isset($contact->$var))
939
+                        $bean->$field = $contact->$var;
940
+                }
941
+            }
942
+    }
943 943
 
944 944
 
945 945
     protected function findRelationship(
@@ -947,12 +947,12 @@  discard block
 block discarded – undo
947 947
         $to
948 948
         )
949 949
     {
950
-    	global $dictionary;
951
-    	require_once("modules/TableDictionary.php");
952
-    	foreach ($from->field_defs as $field=>$def)
950
+        global $dictionary;
951
+        require_once("modules/TableDictionary.php");
952
+        foreach ($from->field_defs as $field=>$def)
953 953
         {
954 954
             if (isset($def['type']) && $def['type'] == "link" && isset($def['relationship'])) 
955
-			{
955
+            {
956 956
                 $rel_name = $def['relationship'];
957 957
                 $rel_def = "";
958 958
                 if (isset($dictionary[$from->object_name]['relationships']) && isset($dictionary[$from->object_name]['relationships'][$rel_name]))
@@ -966,16 +966,16 @@  discard block
 block discarded – undo
966 966
                 else if (isset($dictionary[$rel_name]) && isset($dictionary[$rel_name]['relationships'])
967 967
                         && isset($dictionary[$rel_name]['relationships'][$rel_name]))
968 968
                 {
969
-                	$rel_def = $dictionary[$rel_name]['relationships'][$rel_name];
969
+                    $rel_def = $dictionary[$rel_name]['relationships'][$rel_name];
970 970
                 }
971 971
                 if (!empty($rel_def)) {
972 972
                     if ($rel_def['lhs_module'] == $from->module_dir && $rel_def['rhs_module'] == $to->module_dir )
973 973
                     {
974
-                    	return $field;
974
+                        return $field;
975 975
                     }
976 976
                     else if ($rel_def['rhs_module'] == $from->module_dir && $rel_def['lhs_module'] == $to->module_dir )
977 977
                     {
978
-                    	return $field;
978
+                        return $field;
979 979
                     }
980 980
                 }
981 981
             }
@@ -996,16 +996,16 @@  discard block
 block discarded – undo
996 996
         }
997 997
         return false;
998 998
     }
999
-	/**
1000
-	 * @see SugarView::_getModuleTitleParams()
1001
-	 */
1002
-	protected function _getModuleTitleParams($browserTitle = false)
1003
-	{
1004
-	    global $mod_strings;
1005
-	    $params = parent::_getModuleTitleParams($browserTitle);
1006
-	    $params[] = "<a href='index.php?module=Leads&action=DetailView&record={$this->bean->id}'>{$this->bean->name}</a>";
1007
-	    $params[] = $mod_strings['LBL_CONVERTLEAD'];
1008
-    	return $params;
999
+    /**
1000
+     * @see SugarView::_getModuleTitleParams()
1001
+     */
1002
+    protected function _getModuleTitleParams($browserTitle = false)
1003
+    {
1004
+        global $mod_strings;
1005
+        $params = parent::_getModuleTitleParams($browserTitle);
1006
+        $params[] = "<a href='index.php?module=Leads&action=DetailView&record={$this->bean->id}'>{$this->bean->name}</a>";
1007
+        $params[] = $mod_strings['LBL_CONVERTLEAD'];
1008
+        return $params;
1009 1009
     }
1010 1010
 
1011 1011
 
@@ -1013,27 +1013,27 @@  discard block
 block discarded – undo
1013 1013
         $lead
1014 1014
         )
1015 1015
     {
1016
-    	if ($lead->status == "Converted")
1017
-    	{
1018
-    		echo ("<span class='error'>" . translate('LBL_CONVERTLEAD_WARNING'));
1019
-    		$dupes = array();
1020
-    		$q = "SELECT id, first_name, last_name FROM contacts WHERE first_name LIKE '{$lead->first_name}' AND last_name LIKE '{$lead->last_name}' AND deleted = 0";
1021
-    		$result = $lead->db->query($q);
1022
-    		while($row = $lead->db->fetchByAssoc($result)) {
1023
-    			$contact = new Contact();
1024
-    			$contact->retrieve($row['id']);
1025
-    			$dupes[$row['id']] = $contact->name;
1026
-    		}
1027
-    		if (!empty($dupes))
1028
-    		{
1029
-    			foreach($dupes as $id => $name)
1030
-    			{
1031
-    				echo (translate('LBL_CONVERTLEAD_WARNING_INTO_RECORD') . "<a href='index.php?module=Contacts&action=DetailView&record=$id'>$name</a>");
1032
-    				break;
1033
-    			}
1034
-    		}
1035
-    		echo "</span>";
1036
-    	}
1037
-    	return false;
1016
+        if ($lead->status == "Converted")
1017
+        {
1018
+            echo ("<span class='error'>" . translate('LBL_CONVERTLEAD_WARNING'));
1019
+            $dupes = array();
1020
+            $q = "SELECT id, first_name, last_name FROM contacts WHERE first_name LIKE '{$lead->first_name}' AND last_name LIKE '{$lead->last_name}' AND deleted = 0";
1021
+            $result = $lead->db->query($q);
1022
+            while($row = $lead->db->fetchByAssoc($result)) {
1023
+                $contact = new Contact();
1024
+                $contact->retrieve($row['id']);
1025
+                $dupes[$row['id']] = $contact->name;
1026
+            }
1027
+            if (!empty($dupes))
1028
+            {
1029
+                foreach($dupes as $id => $name)
1030
+                {
1031
+                    echo (translate('LBL_CONVERTLEAD_WARNING_INTO_RECORD') . "<a href='index.php?module=Contacts&action=DetailView&record=$id'>$name</a>");
1032
+                    break;
1033
+                }
1034
+            }
1035
+            echo "</span>";
1036
+        }
1037
+        return false;
1038 1038
     }
1039 1039
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 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.
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
             $this->medataDataFile = "custom/{$editviewFile}";
89 89
         }
90 90
     	include($this->medataDataFile);
91
-    	foreach($viewdefs['Leads']['EditView']['panels'] as $panel_index => $section){
92
-    	    foreach($section as $row_array){
93
-    	        foreach($row_array as $cell){
94
-        	        if(isset($cell['name']) && $cell['name'] == 'opportunity_name'){
91
+    	foreach ($viewdefs['Leads']['EditView']['panels'] as $panel_index => $section) {
92
+    	    foreach ($section as $row_array) {
93
+    	        foreach ($row_array as $cell) {
94
+        	        if (isset($cell['name']) && $cell['name'] == 'opportunity_name') {
95 95
         	            $opportunityNameInLayout = true;
96 96
         	        }
97 97
     	        }
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
         // Check if Lead has an account set
126 126
         if (!empty($this->focus->account_name))
127 127
         {
128
-            $filter .= '&name_advanced=' . urlencode($this->focus->account_name);
128
+            $filter .= '&name_advanced='.urlencode($this->focus->account_name);
129 129
         }
130 130
         // Check if Lead First name is available
131 131
         if (!empty($this->focus->first_name))
132 132
         {
133
-            $filter .= '&first_name_advanced=' . urlencode($this->focus->first_name);
133
+            $filter .= '&first_name_advanced='.urlencode($this->focus->first_name);
134 134
         }
135 135
         // Lead Last Name is always available
136
-        $filter .= '&last_name_advanced=' . urlencode($this->focus->last_name);
136
+        $filter .= '&last_name_advanced='.urlencode($this->focus->last_name);
137 137
         
138 138
         $smarty->assign('initialFilter', $filter);
139 139
         $smarty->assign('displayParams', array('initial_filter' => '{$initialFilter}'));
@@ -176,20 +176,20 @@  discard block
 block discarded – undo
176 176
         $smarty->assign('lead_conv_activity_opt', $sugar_config['lead_conv_activity_opt']);
177 177
         
178 178
         //Switch up list depending on copy or move
179
-        if($sugar_config['lead_conv_activity_opt'] == 'move')
179
+        if ($sugar_config['lead_conv_activity_opt'] == 'move')
180 180
         {
181 181
         	$smarty->assign('convertModuleListOptions', get_select_options_with_id(array('None'=>$app_strings['LBL_NONE'], 'Contacts' => $app_list_strings["moduleListSingular"]['Contacts']), ''));	
182 182
         }
183
-        else if($sugar_config['lead_conv_activity_opt'] == 'copy')
183
+        else if ($sugar_config['lead_conv_activity_opt'] == 'copy')
184 184
         {
185 185
         	$smarty->assign('convertModuleListOptions', get_select_options_with_id(array('Contacts' => $app_list_strings["moduleListSingular"]['Contacts']), ''));
186 186
         }
187 187
         
188 188
         
189 189
 
190
-        foreach($this->defs as $module => $vdef)
190
+        foreach ($this->defs as $module => $vdef)
191 191
         {
192
-            if(!isset($beanList[$module]))
192
+            if (!isset($beanList[$module]))
193 193
             {
194 194
                 continue;
195 195
             }
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
             }
206 206
 
207 207
             $focus->fill_in_additional_detail_fields();
208
-            foreach($focus->field_defs as $field => $def)
208
+            foreach ($focus->field_defs as $field => $def)
209 209
             {
210
-            	if(isset($vdef[$ev->view]['copyData']) && $vdef[$ev->view]['copyData'])
210
+            	if (isset($vdef[$ev->view]['copyData']) && $vdef[$ev->view]['copyData'])
211 211
                 {
212 212
 	                if ($module == "Accounts" && $field == 'name')
213 213
 	                {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	                    $focus->amount = unformat_number($this->focus->opportunity_amount);
219 219
 	                } 
220 220
                  	else if ($module == "Opportunities" && $field == 'name') {
221
-                 		if ($opportunityNameInLayout && !empty($this->focus->opportunity_name)){
221
+                 		if ($opportunityNameInLayout && !empty($this->focus->opportunity_name)) {
222 222
                            $focus->name = $this->focus->opportunity_name;
223 223
                  		}
224 224
                    	}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         )
302 302
     {
303 303
         $validateSelect = isset($viewdef['required']) && $viewdef['required'] && !empty($viewdef['select']);
304
-        $jsOut  = "
304
+        $jsOut = "
305 305
         <script type='text/javascript'>
306 306
             if (!SUGAR.convert)  SUGAR.convert = {requiredFields: {}};
307 307
             SUGAR.convert.toggle$module = function(){
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                     }
316 316
                     ";
317 317
         if ($validateSelect) {
318
-        	$jsOut  .= "
318
+        	$jsOut .= "
319 319
                     removeFromValidate('ConvertLead', '{$viewdef['select']}');";
320 320
         }
321 321
 
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
                         removeFromValidate('ConvertLead', '$module' + i);
328 328
                     }";
329 329
         if ($validateSelect) {
330
-            $jsOut  .= "
330
+            $jsOut .= "
331 331
                 addToValidate('ConvertLead', '{$viewdef['select']}', 'varchar', true, '"
332
-            . translate($this->contact->field_defs[$viewdef['select']]['vname']) . "');";
332
+            . translate($this->contact->field_defs[$viewdef['select']]['vname'])."');";
333 333
         }
334 334
         $jsOut .= "
335 335
                     SUGAR.convert.{$module}Enabled = false;
@@ -346,19 +346,19 @@  discard block
 block discarded – undo
346 346
             }
347 347
             $jsOut .= "
348 348
             YAHOO.util.Event.onDOMReady(SUGAR.convert.toggle$module);";
349
-        } else if (isset($viewdef['default_action'])  && $viewdef['default_action'] == "create")
349
+        } else if (isset($viewdef['default_action']) && $viewdef['default_action'] == "create")
350 350
         {
351 351
              $jsOut .= "\n            SUGAR.convert.{$module}Enabled = true;";
352 352
         }
353 353
         $jsOut .= "
354 354
             YAHOO.util.Event.addListener('new$module', 'click', SUGAR.convert.toggle$module);
355 355
             SUGAR.convert.requiredFields.$module = {};";
356
-        foreach($focus->field_defs as $field => $def)
356
+        foreach ($focus->field_defs as $field => $def)
357 357
         {
358 358
             if (isset($def['required']) && $def['required'])
359 359
             {
360 360
                 $jsOut .= "
361
-            SUGAR.convert.requiredFields.$module.$field = '". translate($def['vname'], $module) . "';\n";
361
+            SUGAR.convert.requiredFields.$module.$field = '".translate($def['vname'], $module)."';\n";
362 362
             }
363 363
         }
364 364
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 
413 413
             if (isset($duplicateContacts))
414 414
             {
415
-                echo $contactForm->buildTableForm($duplicateContacts,  'Contacts');
415
+                echo $contactForm->buildTableForm($duplicateContacts, 'Contacts');
416 416
                 return;
417 417
             }
418 418
             $this->new_contact = true;
@@ -604,26 +604,26 @@  discard block
 block discarded – undo
604 604
     {
605 605
     	global $beanList;
606 606
     	echo "<div><ul>";
607
-        foreach($beans as $bean)
607
+        foreach ($beans as $bean)
608 608
         {
609 609
             $beanName = $bean->object_name;
610
-            if ( $beanName == 'Contact' && !$this->new_contact ) {
611
-                echo "<li>" . translate("LBL_EXISTING_CONTACT") . " -
610
+            if ($beanName == 'Contact' && !$this->new_contact) {
611
+                echo "<li>".translate("LBL_EXISTING_CONTACT")." -
612 612
                     <a href='index.php?module={$bean->module_dir}&action=DetailView&record={$bean->id}'>
613 613
                        {$bean->get_summary_text()}
614 614
                     </a></li>";
615 615
             }
616 616
             else {
617 617
                 global $app_list_strings;
618
-                if(!empty($app_list_strings['moduleListSingular'][$bean->module_dir])) {
618
+                if (!empty($app_list_strings['moduleListSingular'][$bean->module_dir])) {
619 619
                     $module_name = $app_list_strings['moduleListSingular'][$bean->module_dir];
620 620
                 } else {
621 621
                     $module_name = translate('LBL_MODULE_NAME', $bean->module_dir);
622 622
                 }
623
-                if(empty($module_name)) {
623
+                if (empty($module_name)) {
624 624
                     $module_name = translate($beanName);
625 625
                 }
626
-                echo "<li>" . translate("LBL_CREATED_NEW") . ' ' . $module_name . " -
626
+                echo "<li>".translate("LBL_CREATED_NEW").' '.$module_name." -
627 627
                     <a href='index.php?module={$bean->module_dir}&action=DetailView&record={$bean->id}'>
628 628
                        {$bean->get_summary_text()}
629 629
                     </a></li>";
@@ -649,17 +649,17 @@  discard block
 block discarded – undo
649 649
         $accountParentInfo = array();
650 650
 
651 651
         //determine the account id info ahead of time if it is being created as part of this conversion
652
-        if(!empty($beans['Accounts'])){
652
+        if (!empty($beans['Accounts'])) {
653 653
             $account_id = create_guid();
654
-            if(!empty($beans['Accounts']->id)){
654
+            if (!empty($beans['Accounts']->id)) {
655 655
                 $account_id = $beans['Accounts']->id;
656
-            }else{
656
+            } else {
657 657
                 $beans['Accounts']->id = $account_id;
658 658
             }
659
-            $accountParentInfo = array('id'=>$account_id,'type'=>'Accounts');
659
+            $accountParentInfo = array('id'=>$account_id, 'type'=>'Accounts');
660 660
         }
661 661
 
662
-    	foreach($beans as $module => $bean)
662
+    	foreach ($beans as $module => $bean)
663 663
     	{
664 664
 	    	if (isset($parent_types[$module]))
665 665
 	    	{
@@ -668,9 +668,9 @@  discard block
 block discarded – undo
668 668
                     $bean->id = create_guid();
669 669
 		            $bean->new_with_id = true;
670 670
                 }
671
-                if( isset($_POST['lead_conv_ac_op_sel']) && $_POST['lead_conv_ac_op_sel'] != 'None')
671
+                if (isset($_POST['lead_conv_ac_op_sel']) && $_POST['lead_conv_ac_op_sel'] != 'None')
672 672
                 {
673
-	                foreach($activities as $activity)
673
+	                foreach ($activities as $activity)
674 674
 			    	{
675 675
 	                            if (!isset($sugar_config['lead_conv_activity_opt']) || $sugar_config['lead_conv_activity_opt'] == 'copy') {
676 676
 	                                if (isset($_POST['lead_conv_ac_op_sel'])) {
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 
715 715
         // delete the old relationship to the old parent (lead)
716 716
         if ($rel = $this->findRelationship($activity, $lead)) {
717
-            $activity->load_relationship ($rel) ;
717
+            $activity->load_relationship($rel);
718 718
 
719 719
             if ($activity->parent_id && $activity->id) {
720 720
                 $activity->$rel->delete($activity->id, $activity->parent_id);
@@ -723,10 +723,10 @@  discard block
 block discarded – undo
723 723
 
724 724
         // add the new relationship to the new parent (contact, account, etc)
725 725
         if ($rel = $this->findRelationship($activity, $bean)) {
726
-            $activity->load_relationship ($rel) ;
726
+            $activity->load_relationship($rel);
727 727
 
728 728
             $relObj = $activity->$rel->getRelationshipObject();
729
-            if ( $relObj->relationship_type=='one-to-one' || $relObj->relationship_type == 'one-to-many' )
729
+            if ($relObj->relationship_type == 'one-to-one' || $relObj->relationship_type == 'one-to-many')
730 730
             {
731 731
                 $key = $relObj->rhs_key;
732 732
                 $activity->$key = $bean->id;
@@ -757,13 +757,13 @@  discard block
 block discarded – undo
757 757
 		$activitesList = array("Calls", "Tasks", "Meetings", "Emails", "Notes");
758 758
 		$activities = array();
759 759
 
760
-		foreach($activitesList as $module)
760
+		foreach ($activitesList as $module)
761 761
 		{
762 762
 			$beanName = $beanList[$module];
763 763
 			$activity = new $beanName();
764 764
 			$query = "SELECT id FROM {$activity->table_name} WHERE parent_id = '{$lead->id}' AND parent_type = 'Leads' AND deleted = 0";
765
-			$result = $db->query($query,true);
766
-            while($row = $db->fetchByAssoc($result))
765
+			$result = $db->query($query, true);
766
+            while ($row = $db->fetchByAssoc($result))
767 767
             {
768 768
             	$activity = new $beanName();
769 769
 				$activity->retrieve($row['id']);
@@ -790,12 +790,12 @@  discard block
 block discarded – undo
790 790
         //set the parent id and type if it was passed in, otherwise use blank to wipe it out
791 791
         $parentID = '';
792 792
         $parentType = '';
793
-        if(!empty($parentArr)){
794
-            if(!empty($parentArr['id'])){
793
+        if (!empty($parentArr)) {
794
+            if (!empty($parentArr['id'])) {
795 795
                 $parentID = $parentArr['id'];
796 796
             }
797 797
 
798
-            if(!empty($parentArr['type'])){
798
+            if (!empty($parentArr['type'])) {
799 799
                 $parentType = $parentArr['type'];
800 800
             }
801 801
 
@@ -815,9 +815,9 @@  discard block
 block discarded – undo
815 815
                 $newActivity->$rel = '';
816 816
             }
817 817
 
818
-            $newActivity->load_relationship ($rel) ;
818
+            $newActivity->load_relationship($rel);
819 819
             $relObj = $newActivity->$rel->getRelationshipObject();
820
-            if ( $relObj->relationship_type=='one-to-one' || $relObj->relationship_type == 'one-to-many' )
820
+            if ($relObj->relationship_type == 'one-to-one' || $relObj->relationship_type == 'one-to-many')
821 821
             {
822 822
                 $key = $relObj->rhs_key;
823 823
                 $newActivity->$key = $bean->id;
@@ -825,14 +825,14 @@  discard block
 block discarded – undo
825 825
 
826 826
             //parent (related to field) should be blank unless it is explicitly sent in
827 827
             //it is not sent in unless the account is being created as well during lead conversion
828
-            $newActivity->parent_id =  $parentID;
828
+            $newActivity->parent_id = $parentID;
829 829
             $newActivity->parent_type = $parentType;
830 830
 
831 831
 	        $newActivity->update_date_modified = false; //bug 41747
832 832
 	        $newActivity->save();
833 833
             $newActivity->$rel->add($bean);
834 834
             if ($newActivity->module_dir == "Notes" && $newActivity->filename) {
835
-	        	UploadFile::duplicate_file($activity->id, $newActivity->id,  $newActivity->filename);
835
+	        	UploadFile::duplicate_file($activity->id, $newActivity->id, $newActivity->filename);
836 836
 	        }
837 837
          }
838 838
 	}
@@ -851,12 +851,12 @@  discard block
 block discarded – undo
851 851
 	    )
852 852
 	{
853 853
 		//Copy data from the contact to new bean
854
-		foreach($bean->field_defs as $field => $def)
854
+		foreach ($bean->field_defs as $field => $def)
855 855
 		{
856
-			if(!isset($_REQUEST[$module . $field]) && isset($lead->$field) && $field != 'id')
856
+			if (!isset($_REQUEST[$module.$field]) && isset($lead->$field) && $field != 'id')
857 857
 			{
858 858
 				$bean->$field = $lead->$field;
859
-				if($field == 'date_entered') $bean->$field = gmdate($GLOBALS['timedate']->get_db_date_time_format()); //bug 41030
859
+				if ($field == 'date_entered') $bean->$field = gmdate($GLOBALS['timedate']->get_db_date_time_format()); //bug 41030
860 860
 			}
861 861
 		}
862 862
         populateFromPost($module, $bean, true);
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 				$bean->id = create_guid();
872 872
 				$bean->new_with_id = true;
873 873
                 $idName = $fieldDef['id_name'];
874
-				$contact->$idName = $bean->id ;
874
+				$contact->$idName = $bean->id;
875 875
 				if ($idName != $select) {
876 876
 					$rname = isset($fieldDef['rname']) ? $fieldDef['rname'] : "";
877 877
 					if (!empty($rname) && isset($bean->$rname))
@@ -880,13 +880,13 @@  discard block
 block discarded – undo
880 880
 						$contact->$select = $bean->name;
881 881
 				}
882 882
 			}
883
-		} else if ($module != "Contacts"){
883
+		} else if ($module != "Contacts") {
884 884
 			$contactRel = $this->findRelationship($contact, $bean);
885 885
 			if (!empty($contactRel))
886 886
 			{
887 887
 				$bean->id = create_guid();
888 888
 				$bean->new_with_id = true;
889
-				$contact->load_relationship ($contactRel) ;
889
+				$contact->load_relationship($contactRel);
890 890
 				$relObject = $contact->$contactRel->getRelationshipObject();
891 891
 				if ($relObject->relationship_type == "one-to-many" && $contact->$contactRel->_get_bean_position())
892 892
 				{
@@ -908,30 +908,30 @@  discard block
 block discarded – undo
908 908
 	protected function copyAddressFields($bean, $contact)
909 909
 	{
910 910
 	//Copy over address info from the contact to any beans with address not set
911
-	        foreach($bean->field_defs as $field => $def)
911
+	        foreach ($bean->field_defs as $field => $def)
912 912
 			{
913
-				if(!isset($_REQUEST[$bean->module_dir . $field]) && strpos($field, "_address_") !== false)
913
+				if (!isset($_REQUEST[$bean->module_dir.$field]) && strpos($field, "_address_") !== false)
914 914
 				{
915 915
 					$set = "primary";
916 916
 					if (strpos($field, "alt_") !== false || strpos($field, "shipping_") !== false)
917 917
 						$set = "alt";
918 918
 					$type = "";
919 919
 
920
-					if(strpos($field, "_address_street_2") !== false)
920
+					if (strpos($field, "_address_street_2") !== false)
921 921
 						$type = "_address_street_2";
922
-					else if(strpos($field, "_address_street_3") !== false)
922
+					else if (strpos($field, "_address_street_3") !== false)
923 923
 						$type = "_address_street_3";
924
-					else if(strpos($field, "_address_street_4") !== false)
924
+					else if (strpos($field, "_address_street_4") !== false)
925 925
 						$type = "";
926
-					else if(strpos($field, "_address_street") !== false)
926
+					else if (strpos($field, "_address_street") !== false)
927 927
 						$type = "_address_street";
928
-					else if(strpos($field, "_address_city") !== false)
928
+					else if (strpos($field, "_address_city") !== false)
929 929
 						$type = "_address_city";
930
-					else if(strpos($field, "_address_state") !== false)
930
+					else if (strpos($field, "_address_state") !== false)
931 931
 						$type = "_address_state";
932
-					else if(strpos($field, "_address_postalcode") !== false)
932
+					else if (strpos($field, "_address_postalcode") !== false)
933 933
 						$type = "_address_postalcode";
934
-					else if(strpos($field, "_address_country") !== false)
934
+					else if (strpos($field, "_address_country") !== false)
935 935
 						$type = "_address_country";
936 936
 
937 937
 						$var = $set.$type;
@@ -969,11 +969,11 @@  discard block
 block discarded – undo
969 969
                 	$rel_def = $dictionary[$rel_name]['relationships'][$rel_name];
970 970
                 }
971 971
                 if (!empty($rel_def)) {
972
-                    if ($rel_def['lhs_module'] == $from->module_dir && $rel_def['rhs_module'] == $to->module_dir )
972
+                    if ($rel_def['lhs_module'] == $from->module_dir && $rel_def['rhs_module'] == $to->module_dir)
973 973
                     {
974 974
                     	return $field;
975 975
                     }
976
-                    else if ($rel_def['rhs_module'] == $from->module_dir && $rel_def['lhs_module'] == $to->module_dir )
976
+                    else if ($rel_def['rhs_module'] == $from->module_dir && $rel_def['lhs_module'] == $to->module_dir)
977 977
                     {
978 978
                     	return $field;
979 979
                     }
@@ -1015,20 +1015,20 @@  discard block
 block discarded – undo
1015 1015
     {
1016 1016
     	if ($lead->status == "Converted")
1017 1017
     	{
1018
-    		echo ("<span class='error'>" . translate('LBL_CONVERTLEAD_WARNING'));
1018
+    		echo ("<span class='error'>".translate('LBL_CONVERTLEAD_WARNING'));
1019 1019
     		$dupes = array();
1020 1020
     		$q = "SELECT id, first_name, last_name FROM contacts WHERE first_name LIKE '{$lead->first_name}' AND last_name LIKE '{$lead->last_name}' AND deleted = 0";
1021 1021
     		$result = $lead->db->query($q);
1022
-    		while($row = $lead->db->fetchByAssoc($result)) {
1022
+    		while ($row = $lead->db->fetchByAssoc($result)) {
1023 1023
     			$contact = new Contact();
1024 1024
     			$contact->retrieve($row['id']);
1025 1025
     			$dupes[$row['id']] = $contact->name;
1026 1026
     		}
1027 1027
     		if (!empty($dupes))
1028 1028
     		{
1029
-    			foreach($dupes as $id => $name)
1029
+    			foreach ($dupes as $id => $name)
1030 1030
     			{
1031
-    				echo (translate('LBL_CONVERTLEAD_WARNING_INTO_RECORD') . "<a href='index.php?module=Contacts&action=DetailView&record=$id'>$name</a>");
1031
+    				echo (translate('LBL_CONVERTLEAD_WARNING_INTO_RECORD')."<a href='index.php?module=Contacts&action=DetailView&record=$id'>$name</a>");
1032 1032
     				break;
1033 1033
     			}
1034 1034
     		}
Please login to merge, or discard this patch.
modules/UpgradeWizard/silentUpgrade_dce_step2.php 3 patches
Indentation   +377 added lines, -377 removed lines patch added patch discarded remove patch
@@ -47,128 +47,128 @@  discard block
 block discarded – undo
47 47
 ////	UTILITIES THAT MUST BE LOCAL :(
48 48
 //local function for clearing cache
49 49
 function clearCacheSU($thedir, $extension) {
50
-	if ($current = @opendir($thedir)) {
51
-		while (false !== ($children = readdir($current))) {
52
-			if ($children != "." && $children != "..") {
53
-				if (is_dir($thedir . "/" . $children)) {
54
-					clearCacheSU($thedir . "/" . $children, $extension);
55
-				}
56
-				elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
57
-					unlink($thedir . "/" . $children);
58
-				}
59
-			}
60
-		}
61
-	}
62
- }
63
- //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
64
- //no found then adds default_permissions to the config file.
65
- function checkConfigForPermissions(){
66
-     if(file_exists(getcwd().'/config.php')){
67
-         require(getcwd().'/config.php');
68
-     }
69
-     global $sugar_config;
70
-     if(!isset($sugar_config['default_permissions'])){
71
-             $sugar_config['default_permissions'] = array (
72
-                     'dir_mode' => 02770,
73
-                     'file_mode' => 0660,
74
-                     'user' => '',
75
-                     'group' => '',
76
-             );
77
-         ksort($sugar_config);
78
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
79
-        	//writing to the file
80
- 		}
81
-     }
50
+    if ($current = @opendir($thedir)) {
51
+        while (false !== ($children = readdir($current))) {
52
+            if ($children != "." && $children != "..") {
53
+                if (is_dir($thedir . "/" . $children)) {
54
+                    clearCacheSU($thedir . "/" . $children, $extension);
55
+                }
56
+                elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
57
+                    unlink($thedir . "/" . $children);
58
+                }
59
+            }
60
+        }
61
+    }
62
+    }
63
+    //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
64
+    //no found then adds default_permissions to the config file.
65
+    function checkConfigForPermissions(){
66
+        if(file_exists(getcwd().'/config.php')){
67
+            require(getcwd().'/config.php');
68
+        }
69
+        global $sugar_config;
70
+        if(!isset($sugar_config['default_permissions'])){
71
+                $sugar_config['default_permissions'] = array (
72
+                        'dir_mode' => 02770,
73
+                        'file_mode' => 0660,
74
+                        'user' => '',
75
+                        'group' => '',
76
+                );
77
+            ksort($sugar_config);
78
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
79
+            //writing to the file
80
+            }
81
+        }
82 82
 }
83 83
 function checkLoggerSettings(){
84
-	if(file_exists(getcwd().'/config.php')){
85
-         require(getcwd().'/config.php');
86
-     }
84
+    if(file_exists(getcwd().'/config.php')){
85
+            require(getcwd().'/config.php');
86
+        }
87 87
     global $sugar_config;
88
-	if(!isset($sugar_config['logger'])){
89
-	    $sugar_config['logger'] =array (
90
-			'level'=>'fatal',
91
-		    'file' =>
92
-		     array (
93
-		      'ext' => '.log',
94
-		      'name' => 'sugarcrm',
95
-		      'dateFormat' => '%c',
96
-		      'maxSize' => '10MB',
97
-		      'maxLogs' => 10,
98
-		      'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
99
-		    ),
100
-		  );
101
-		 ksort($sugar_config);
102
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
103
-        	//writing to the file
104
- 		}
105
-	 }
88
+    if(!isset($sugar_config['logger'])){
89
+        $sugar_config['logger'] =array (
90
+            'level'=>'fatal',
91
+            'file' =>
92
+                array (
93
+                'ext' => '.log',
94
+                'name' => 'sugarcrm',
95
+                'dateFormat' => '%c',
96
+                'maxSize' => '10MB',
97
+                'maxLogs' => 10,
98
+                'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
99
+            ),
100
+            );
101
+            ksort($sugar_config);
102
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
103
+            //writing to the file
104
+            }
105
+        }
106 106
 }
107 107
 
108 108
 function checkResourceSettings(){
109
-	if(file_exists(getcwd().'/config.php')){
110
-         require(getcwd().'/config.php');
111
-     }
109
+    if(file_exists(getcwd().'/config.php')){
110
+            require(getcwd().'/config.php');
111
+        }
112 112
     global $sugar_config;
113
-	if(!isset($sugar_config['resource_management'])){
114
-	  $sugar_config['resource_management'] =
115
-		  array (
116
-		    'special_query_limit' => 50000,
117
-		    'special_query_modules' =>
118
-		    array (
119
-		      0 => 'Reports',
120
-		      1 => 'Export',
121
-		      2 => 'Import',
122
-		      3 => 'Administration',
123
-		      4 => 'Sync',
124
-		    ),
125
-		    'default_limit' => 1000,
126
-		  );
127
-		 ksort($sugar_config);
128
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
129
-        	//writing to the file
130
- 		}
131
-	}
113
+    if(!isset($sugar_config['resource_management'])){
114
+        $sugar_config['resource_management'] =
115
+            array (
116
+            'special_query_limit' => 50000,
117
+            'special_query_modules' =>
118
+            array (
119
+                0 => 'Reports',
120
+                1 => 'Export',
121
+                2 => 'Import',
122
+                3 => 'Administration',
123
+                4 => 'Sync',
124
+            ),
125
+            'default_limit' => 1000,
126
+            );
127
+            ksort($sugar_config);
128
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
129
+            //writing to the file
130
+            }
131
+    }
132 132
 }
133 133
 
134 134
 function createMissingRels(){
135
-	$relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
136
-	foreach($relForObjects as $relObjName=>$relModName){
137
-		//assigned_user
138
-		$guid = create_guid();
139
-		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
140
-		$result= $GLOBALS['db']->query($query, true);
141
-		$a = null;
142
-		$a = $GLOBALS['db']->fetchByAssoc($result);
143
-		if(!isset($a['id']) && empty($a['id']) ){
144
-			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
135
+    $relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
136
+    foreach($relForObjects as $relObjName=>$relModName){
137
+        //assigned_user
138
+        $guid = create_guid();
139
+        $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
140
+        $result= $GLOBALS['db']->query($query, true);
141
+        $a = null;
142
+        $a = $GLOBALS['db']->fetchByAssoc($result);
143
+        if(!isset($a['id']) && empty($a['id']) ){
144
+            $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
145 145
 						VALUES ('{$guid}', '{$relObjName}_assigned_user','Users','users','id','{$relModName}','{$relObjName}','assigned_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
146
-			$GLOBALS['db']->query($qRel);
147
-		}
148
-		//modified_user
149
-		$guid = create_guid();
150
-		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
151
-		$result= $GLOBALS['db']->query($query, true);
152
-		$a = null;
153
-		$a = $GLOBALS['db']->fetchByAssoc($result);
154
-		if(!isset($a['id']) && empty($a['id']) ){
155
-			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
146
+            $GLOBALS['db']->query($qRel);
147
+        }
148
+        //modified_user
149
+        $guid = create_guid();
150
+        $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
151
+        $result= $GLOBALS['db']->query($query, true);
152
+        $a = null;
153
+        $a = $GLOBALS['db']->fetchByAssoc($result);
154
+        if(!isset($a['id']) && empty($a['id']) ){
155
+            $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
156 156
 						VALUES ('{$guid}', '{$relObjName}_modified_user','Users','users','id','{$relModName}','{$relObjName}','modified_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
157
-			$GLOBALS['db']->query($qRel);
158
-		}
159
-		//created_by
160
-		$guid = create_guid();
161
-		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
162
-		$result= $GLOBALS['db']->query($query, true);
163
-		$a = null;
164
-		$a = $GLOBALS['db']->fetchByAssoc($result);
165
-    	if(!isset($a['id']) && empty($a['id']) ){
166
-			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
157
+            $GLOBALS['db']->query($qRel);
158
+        }
159
+        //created_by
160
+        $guid = create_guid();
161
+        $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
162
+        $result= $GLOBALS['db']->query($query, true);
163
+        $a = null;
164
+        $a = $GLOBALS['db']->fetchByAssoc($result);
165
+        if(!isset($a['id']) && empty($a['id']) ){
166
+            $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
167 167
 						VALUES ('{$guid}', '{$relObjName}_created_by','Users','users','id','{$relModName}','{$relObjName}','created_by',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
168
-			$GLOBALS['db']->query($qRel);
169
-    	}
170
-	}
171
-	//Also add tracker perf relationship
168
+            $GLOBALS['db']->query($qRel);
169
+        }
170
+    }
171
+    //Also add tracker perf relationship
172 172
 }
173 173
 
174 174
 
@@ -212,22 +212,22 @@  discard block
 block discarded – undo
212 212
 }
213 213
 
214 214
 function addDefaultModuleRoles($defaultRoles = array()) {
215
-	foreach($defaultRoles as $roleName=>$role){
215
+    foreach($defaultRoles as $roleName=>$role){
216 216
         foreach($role as $category=>$actions){
217 217
             foreach($actions as $name=>$access_override){
218 218
                     $query = "SELECT * FROM acl_actions WHERE name='$name' AND category = '$category' AND acltype='$roleName' AND deleted=0 ";
219
-					$result = $GLOBALS['db']->query($query);
220
-					//only add if an action with that name and category don't exist
221
-					$row=$GLOBALS['db']->fetchByAssoc($result);
222
-					if ($row == null) {
223
-	                	$guid = create_guid();
224
-	                	$currdate = gmdate('Y-m-d H:i:s');
225
-	                	$query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
226
-						$GLOBALS['db']->query($query);
227
-	                }
219
+                    $result = $GLOBALS['db']->query($query);
220
+                    //only add if an action with that name and category don't exist
221
+                    $row=$GLOBALS['db']->fetchByAssoc($result);
222
+                    if ($row == null) {
223
+                        $guid = create_guid();
224
+                        $currdate = gmdate('Y-m-d H:i:s');
225
+                        $query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
226
+                        $GLOBALS['db']->query($query);
227
+                    }
228 228
             }
229 229
         }
230
-	}
230
+    }
231 231
 }
232 232
 
233 233
 function verifyArguments($argv,$usage_dce,$usage_regular){
@@ -300,33 +300,33 @@  discard block
 block discarded – undo
300 300
 }
301 301
 
302 302
 function upgradeDCEFiles($argv,$instanceUpgradePath){
303
-	//copy and update following files from upgrade package
304
-	$upgradeTheseFiles = array('cron.php','download.php','index.php','install.php','soap.php','sugar_version.php','vcal_server.php');
305
-	foreach($upgradeTheseFiles as $file){
306
-		$srcFile = clean_path("{$instanceUpgradePath}/$file");
307
-		$destFile = clean_path("{$argv[3]}/$file");
308
-		if(file_exists($srcFile)){
309
-			if(!is_dir(dirname($destFile))) {
310
-				mkdir_recursive(dirname($destFile)); // make sure the directory exists
311
-			}
312
-			copy_recursive($srcFile,$destFile);
313
-			$_GET['TEMPLATE_PATH'] = $destFile;
314
-			$_GET['CONVERT_FILE_ONLY'] = true;
315
-			if(!class_exists('TemplateConverter')){
316
-				include($argv[7].'templateConverter.php');
317
-			}else{
318
-				TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
319
-			}
303
+    //copy and update following files from upgrade package
304
+    $upgradeTheseFiles = array('cron.php','download.php','index.php','install.php','soap.php','sugar_version.php','vcal_server.php');
305
+    foreach($upgradeTheseFiles as $file){
306
+        $srcFile = clean_path("{$instanceUpgradePath}/$file");
307
+        $destFile = clean_path("{$argv[3]}/$file");
308
+        if(file_exists($srcFile)){
309
+            if(!is_dir(dirname($destFile))) {
310
+                mkdir_recursive(dirname($destFile)); // make sure the directory exists
311
+            }
312
+            copy_recursive($srcFile,$destFile);
313
+            $_GET['TEMPLATE_PATH'] = $destFile;
314
+            $_GET['CONVERT_FILE_ONLY'] = true;
315
+            if(!class_exists('TemplateConverter')){
316
+                include($argv[7].'templateConverter.php');
317
+            }else{
318
+                TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
319
+            }
320 320
 
321 321
 
322
-		}
323
-	}
322
+        }
323
+    }
324 324
 }
325 325
 
326 326
 
327 327
 
328 328
 function threeWayMerge(){
329
-	//using threeway merge apis
329
+    //using threeway merge apis
330 330
 }
331 331
 ////	END UTILITIES THAT MUST BE LOCAL :(
332 332
 ///////////////////////////////////////////////////////////////////////////////
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
 
341 341
 // only run from command line
342 342
 if(isset($_SERVER['HTTP_USER_AGENT'])) {
343
-	fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
344
-	exit(1);
343
+    fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
344
+    exit(1);
345 345
 }
346 346
 //Clean_string cleans out any file  passed in as a parameter
347 347
 $_SERVER['PHP_SELF'] = 'silentUpgrade.php';
@@ -449,18 +449,18 @@  discard block
 block discarded – undo
449 449
 
450 450
 
451 451
 if($upgradeType == constant('DCE_INSTANCE')){
452
-   	//$instanceUpgradePath = "{$argv[1]}/DCEUpgrade/{$zip_from_dir}";
453
-   	//$instanceUpgradePath = "{$argv[1]}";
454
-	include ("ini_setup.php");
452
+        //$instanceUpgradePath = "{$argv[1]}/DCEUpgrade/{$zip_from_dir}";
453
+        //$instanceUpgradePath = "{$argv[1]}";
454
+    include ("ini_setup.php");
455 455
 
456
-	//get new template path for use in later processing
456
+    //get new template path for use in later processing
457 457
     $dceupgrade_pos = strpos($argv[1], '/DCEUpgrade');
458 458
     $newtemplate_path = substr($argv[1], 0, $dceupgrade_pos);
459 459
 
460
-	require("{$argv[4]}/sugar_version.php");
461
-	global $sugar_version;
460
+    require("{$argv[4]}/sugar_version.php");
461
+    global $sugar_version;
462 462
 
463
-	/*
463
+    /*
464 464
 	//require classes if they do not exist, as these were not in pre 550 entrypoint.php and need to be loaded first
465 465
     if(!class_exists('VardefManager')){
466 466
         require_once("{$newtemplate_path}/include/SugarObjects/VardefManager.php");
@@ -473,69 +473,69 @@  discard block
 block discarded – undo
473 473
 	}
474 474
     */
475 475
 
476
-	//load up entrypoint from original template
477
-   	require_once("{$argv[4]}/include/entryPoint.php");
476
+    //load up entrypoint from original template
477
+        require_once("{$argv[4]}/include/entryPoint.php");
478 478
 
479
-	require_once("{$newtemplate_path}/include/utils/zip_utils.php");
480
-	require_once("{$newtemplate_path}/modules/Administration/UpgradeHistory.php");
479
+    require_once("{$newtemplate_path}/include/utils/zip_utils.php");
480
+    require_once("{$newtemplate_path}/modules/Administration/UpgradeHistory.php");
481 481
 
482
-	// We need to run the silent upgrade as the admin user
483
-	require_once("{$newtemplate_path}/modules/Users/User.php");
484
-	global $current_user;
485
-	$current_user = new User();
486
-	$current_user->retrieve('1');
482
+    // We need to run the silent upgrade as the admin user
483
+    require_once("{$newtemplate_path}/modules/Users/User.php");
484
+    global $current_user;
485
+    $current_user = new User();
486
+    $current_user->retrieve('1');
487 487
 
488 488
 
489
-	//This is DCE instance
490
-      global $sugar_config;
491
-      global $sugar_version;
489
+    //This is DCE instance
490
+        global $sugar_config;
491
+        global $sugar_version;
492 492
 //    require_once("{$cwd}/sugar_version.php"); //provides instance version, flavor etc..
493
-     //provides instance version, flavor etc..
493
+        //provides instance version, flavor etc..
494 494
     $isDCEInstance = true;
495 495
     $configOptions = $sugar_config['dbconfig'];
496 496
 
497
-	$GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
498
-	$db				= &DBManagerFactory::getInstance();
499
-       		///////////////////////////////////////////////////////////////////////////////
500
-	////	MAKE SURE PATCH IS COMPATIBLE
497
+    $GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
498
+    $db				= &DBManagerFactory::getInstance();
499
+                ///////////////////////////////////////////////////////////////////////////////
500
+    ////	MAKE SURE PATCH IS COMPATIBLE
501 501
 
502
-	if(is_file("{$argv[1]}/manifest.php")) {
503
-		// provides $manifest array
504
-		include("{$argv[1]}/manifest.php");
505
-	}
506
-	//If Instance then the files will be accessed from Template/DCEUpgrade folder
507
-	$zip_from_dir = '';
502
+    if(is_file("{$argv[1]}/manifest.php")) {
503
+        // provides $manifest array
504
+        include("{$argv[1]}/manifest.php");
505
+    }
506
+    //If Instance then the files will be accessed from Template/DCEUpgrade folder
507
+    $zip_from_dir = '';
508 508
     if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){
509
-	    $zip_from_dir   = $manifest['copy_files']['from_dir'];
510
-	}
509
+        $zip_from_dir   = $manifest['copy_files']['from_dir'];
510
+    }
511 511
 
512
-	$instanceUpgradePath = "{$argv[1]}/{$zip_from_dir}";
513
-	$_SESSION['sugar_version_file'] = '';
514
-	$srcFile = clean_path("{$instanceUpgradePath}/sugar_version.php");
515
-	if(file_exists($srcFile)) {
516
-	   $_SESSION['sugar_version_file'] = $srcFile;
517
-	}
512
+    $instanceUpgradePath = "{$argv[1]}/{$zip_from_dir}";
513
+    $_SESSION['sugar_version_file'] = '';
514
+    $srcFile = clean_path("{$instanceUpgradePath}/sugar_version.php");
515
+    if(file_exists($srcFile)) {
516
+        $_SESSION['sugar_version_file'] = $srcFile;
517
+    }
518 518
 
519 519
 
520
-	global $instancePath;
521
-	$instancePath = $instanceUpgradePath;
522
-	$_SESSION['instancePath'] = $instancePath;
523
-	if(file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")){
524
-		require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
525
-	} else{
526
-		require_once("{$newtemplate_path}/modules/UpgradeWizard/uw_utils.php");
527
-	}
520
+    global $instancePath;
521
+    $instancePath = $instanceUpgradePath;
522
+    $_SESSION['instancePath'] = $instancePath;
523
+    if(file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")){
524
+        require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
525
+    } else{
526
+        require_once("{$newtemplate_path}/modules/UpgradeWizard/uw_utils.php");
527
+    }
528 528
 
529 529
     $ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt' || $manifest['name'] == 'SugarCE to SugarCorp' || $manifest['name'] == 'SugarCE to SugarUlt');
530
-	$_SESSION['upgrade_from_flavor'] = $manifest['name'];
530
+    $_SESSION['upgrade_from_flavor'] = $manifest['name'];
531 531
 
532 532
     //check for db upgrade
533 533
     //check exit on conflicts
534 534
     $skipDBUpgrade = 'no'; //default
535 535
     if($argv[6] != null && !empty($argv[6])){
536
-    	if(strtolower($argv[6]) == 'yes'){
537
-    	  $skipDBUpgrade = 'yes'; //override
538
-    	}
536
+        if(strtolower($argv[6]) == 'yes'){
537
+            $skipDBUpgrade = 'yes'; //override
538
+        }
539 539
     }
540 540
     global $unzip_dir;
541 541
     $unzip_dir = $argv[1];
@@ -544,16 +544,16 @@  discard block
 block discarded – undo
544 544
     $path = $argv[2];
545 545
 
546 546
     if($skipDBUpgrade == 'no'){
547
-    	//upgrade the db
548
-	    ///////////////////////////////////////////////////////////////////////////////
549
-		////	HANDLE PREINSTALL SCRIPTS
550
-		$file = "{$argv[1]}/".constant('SUGARCRM_PRE_INSTALL_FILE');
551
-		if(is_file($file)) {
552
-			include($file);
553
-			logThis('Running pre_install()...', $path);
554
-			pre_install();
555
-			logThis('pre_install() done.', $path);
556
-		}
547
+        //upgrade the db
548
+        ///////////////////////////////////////////////////////////////////////////////
549
+        ////	HANDLE PREINSTALL SCRIPTS
550
+        $file = "{$argv[1]}/".constant('SUGARCRM_PRE_INSTALL_FILE');
551
+        if(is_file($file)) {
552
+            include($file);
553
+            logThis('Running pre_install()...', $path);
554
+            pre_install();
555
+            logThis('pre_install() done.', $path);
556
+        }
557 557
 
558 558
 
559 559
         //run the 3-way merge
@@ -565,23 +565,23 @@  discard block
 block discarded – undo
565 565
             logThis('Finished 3 way merge()...', $path);
566 566
         }
567 567
 
568
-		logThis('Starting post_install()...', $path);
569
-		$file = "{$argv[1]}/".constant('SUGARCRM_POST_INSTALL_FILE');
570
-		if(is_file($file)) {
571
-		    include($file);
572
-			post_install();
573
-		}
574
-		logThis('post_install() done.', $path);
568
+        logThis('Starting post_install()...', $path);
569
+        $file = "{$argv[1]}/".constant('SUGARCRM_POST_INSTALL_FILE');
570
+        if(is_file($file)) {
571
+            include($file);
572
+            post_install();
573
+        }
574
+        logThis('post_install() done.', $path);
575 575
 
576
-    	///////////////////////////////////////////////////////////////////////////////
577
-		//clean vardefs
578
-		logThis('Performing UWrebuild()...', $path);
579
-			UWrebuild();
580
-		logThis('UWrebuild() done.', $path);
576
+        ///////////////////////////////////////////////////////////////////////////////
577
+        //clean vardefs
578
+        logThis('Performing UWrebuild()...', $path);
579
+            UWrebuild();
580
+        logThis('UWrebuild() done.', $path);
581 581
 
582
-		logThis('begin check default permissions .', $path);
583
-	    	checkConfigForPermissions();
584
-	    logThis('end check default permissions .', $path);
582
+        logThis('begin check default permissions .', $path);
583
+            checkConfigForPermissions();
584
+        logThis('end check default permissions .', $path);
585 585
 
586 586
         logThis('begin check logger settings .', $path);
587 587
             checkLoggerSettings();
@@ -605,63 +605,63 @@  discard block
 block discarded – undo
605 605
         include($newtemplate_path.'/include/modules.php');
606 606
         $newModuleList = $moduleList;
607 607
 
608
-		///    RELOAD NEW DEFINITIONS
609
-		global $ACLActions, $beanList, $beanFiles;
610
-		include($newtemplate_path.'/modules/ACLActions/actiondefs.php');
611
-
612
-		//First repair the databse to ensure it is up to date with the new vardefs/tabledefs
613
-		logThis('About to repair the database.', $path);
614
-		//Use Repair and rebuild to update the database.
615
-		global $dictionary;
616
-		require_once($newtemplate_path.'/modules/Administration/QuickRepairAndRebuild.php');
617
-		$rac = new RepairAndClear();
618
-		$rac->clearVardefs();
619
-		$rac->rebuildExtensions();
620
-
621
-		$repairedTables = array();
622
-
623
-		//Force vardefs to be reloaded
624
-		$GLOBALS['reload_vardefs'] = true;
625
-
626
-		foreach ($beanFiles as $bean => $file) {
627
-			if(file_exists($newtemplate_path . '/' . $file) && $bean != 'UpgradeHistory'){
628
-				unset($GLOBALS['dictionary'][$bean]);
629
-				require_once($newtemplate_path . '/' . $file);
630
-
631
-				$focus = new $bean ();
632
-				if(empty($focus->table_name) || isset($repairedTables[$focus->table_name])) {
633
-				   continue;
634
-				}
635
-
636
-				if (($focus instanceOf SugarBean)) {
637
-					$sql = $db->repairTable($focus, true);
638
-					if(!empty($sql)) {
639
-			   		   logThis($sql, $path);
640
-			   		   $repairedTables[$focus->table_name] = true;
641
-					}
642
-				}
643
-			}
644
-		}
608
+        ///    RELOAD NEW DEFINITIONS
609
+        global $ACLActions, $beanList, $beanFiles;
610
+        include($newtemplate_path.'/modules/ACLActions/actiondefs.php');
611
+
612
+        //First repair the databse to ensure it is up to date with the new vardefs/tabledefs
613
+        logThis('About to repair the database.', $path);
614
+        //Use Repair and rebuild to update the database.
615
+        global $dictionary;
616
+        require_once($newtemplate_path.'/modules/Administration/QuickRepairAndRebuild.php');
617
+        $rac = new RepairAndClear();
618
+        $rac->clearVardefs();
619
+        $rac->rebuildExtensions();
620
+
621
+        $repairedTables = array();
622
+
623
+        //Force vardefs to be reloaded
624
+        $GLOBALS['reload_vardefs'] = true;
625
+
626
+        foreach ($beanFiles as $bean => $file) {
627
+            if(file_exists($newtemplate_path . '/' . $file) && $bean != 'UpgradeHistory'){
628
+                unset($GLOBALS['dictionary'][$bean]);
629
+                require_once($newtemplate_path . '/' . $file);
630
+
631
+                $focus = new $bean ();
632
+                if(empty($focus->table_name) || isset($repairedTables[$focus->table_name])) {
633
+                    continue;
634
+                }
635
+
636
+                if (($focus instanceOf SugarBean)) {
637
+                    $sql = $db->repairTable($focus, true);
638
+                    if(!empty($sql)) {
639
+                            logThis($sql, $path);
640
+                            $repairedTables[$focus->table_name] = true;
641
+                    }
642
+                }
643
+            }
644
+        }
645 645
 
646
-		unset ($dictionary);
647
-		include ($newtemplate_path.'/modules/TableDictionary.php');
648
-		foreach ($dictionary as $meta) {
649
-			$tablename = $meta['table'];
646
+        unset ($dictionary);
647
+        include ($newtemplate_path.'/modules/TableDictionary.php');
648
+        foreach ($dictionary as $meta) {
649
+            $tablename = $meta['table'];
650 650
 
651
-			if(isset($repairedTables[$tablename])) {
652
-			   continue;
653
-			}
651
+            if(isset($repairedTables[$tablename])) {
652
+                continue;
653
+            }
654 654
 
655
-			$fielddefs = $meta['fields'];
656
-			$indices = $meta['indices'];
657
-			$sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
658
-			if(!empty($sql)) {
659
-			    logThis($sql, $path);
660
-			    $repairedTables[$tablename] = true;
661
-			}
655
+            $fielddefs = $meta['fields'];
656
+            $indices = $meta['indices'];
657
+            $sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
658
+            if(!empty($sql)) {
659
+                logThis($sql, $path);
660
+                $repairedTables[$tablename] = true;
661
+            }
662 662
 
663
-		}
664
-		logThis('database repaired', $path);
663
+        }
664
+        logThis('database repaired', $path);
665 665
 
666 666
         //include tab controller
667 667
         require_once($newtemplate_path.'/modules/MySettings/TabController.php');
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 
686 686
         //add the new tabs to the array
687 687
         foreach($newModuleList as $nm ){
688
-          $tabs[$nm] = $nm;
688
+            $tabs[$nm] = $nm;
689 689
         }
690 690
 
691 691
         //now assign the modules to system tabs
@@ -694,75 +694,75 @@  discard block
 block discarded – undo
694 694
 
695 695
 
696 696
 
697
-	    if($ce_to_pro_ent){
698
-	    	//add the global team if it does not exist
699
-			$globalteam = new Team();
700
-			$globalteam->retrieve('1');
701
-			include($newtemplate_path.'/modules/Administration/language/en_us.lang.php');
702
-			if(isset($globalteam->name)){
697
+        if($ce_to_pro_ent){
698
+            //add the global team if it does not exist
699
+            $globalteam = new Team();
700
+            $globalteam->retrieve('1');
701
+            include($newtemplate_path.'/modules/Administration/language/en_us.lang.php');
702
+            if(isset($globalteam->name)){
703 703
 
704
-			   echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>';
705
-			   logThis(" Finish Building private teams", $path);
704
+                echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>';
705
+                logThis(" Finish Building private teams", $path);
706 706
 
707
-			}else{
708
-			   $globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team);
709
-			}
707
+            }else{
708
+                $globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team);
709
+            }
710 710
 
711
-	    	//build private teams
712
-		    logThis(" Start Building private teams", $path);
713
-		    upgradeModulesForTeam();
714
-		    logThis(" Finish Building private teams", $path);
711
+            //build private teams
712
+            logThis(" Start Building private teams", $path);
713
+            upgradeModulesForTeam();
714
+            logThis(" Finish Building private teams", $path);
715 715
 
716
-			//build team sets
717
-		    logThis(" Start Building the team_set and team_sets_teams", $path);
718
-		    upgradeModulesForTeamsets();
719
-		    logThis(" Finish Building the team_set and team_sets_teams", $path);
716
+            //build team sets
717
+            logThis(" Start Building the team_set and team_sets_teams", $path);
718
+            upgradeModulesForTeamsets();
719
+            logThis(" Finish Building the team_set and team_sets_teams", $path);
720 720
 
721
-		    //upgrade teams
722
-			if(file_exists($newtemplate_path.'/modules/Administration/upgradeTeams.php')) {
723
-				logThis(" Start {$newtemplate_path}/modules/Administration/upgradeTeams.php", $path);
724
-				include($newtemplate_path.'/modules/Administration/upgradeTeams.php');
725
-				logThis(" Finish {$newtemplate_path}/modules/Administration/upgradeTeams.php", $path);
721
+            //upgrade teams
722
+            if(file_exists($newtemplate_path.'/modules/Administration/upgradeTeams.php')) {
723
+                logThis(" Start {$newtemplate_path}/modules/Administration/upgradeTeams.php", $path);
724
+                include($newtemplate_path.'/modules/Administration/upgradeTeams.php');
725
+                logThis(" Finish {$newtemplate_path}/modules/Administration/upgradeTeams.php", $path);
726 726
 
727
-				//update the users records to have default team
728
-				logThis('running query to populate default_team on users table',$path);
729
-				$GLOBALS['db']->query("update users set default_team = (select teams.id from teams where teams.name = concat('(',users.user_name, ')') or team.associated_user_id = users.id)");
727
+                //update the users records to have default team
728
+                logThis('running query to populate default_team on users table',$path);
729
+                $GLOBALS['db']->query("update users set default_team = (select teams.id from teams where teams.name = concat('(',users.user_name, ')') or team.associated_user_id = users.id)");
730 730
 
731
-			}
731
+            }
732 732
 
733
-			//run upgrade script for dashlets to include sales/marketing
734
-			if(function_exists('upgradeDashletsForSalesAndMarketing')){
735
-	           logThis('calling upgradeDashlets script',$path);
736
-			   upgradeDashletsForSalesAndMarketing();
737
-			}
733
+            //run upgrade script for dashlets to include sales/marketing
734
+            if(function_exists('upgradeDashletsForSalesAndMarketing')){
735
+                logThis('calling upgradeDashlets script',$path);
736
+                upgradeDashletsForSalesAndMarketing();
737
+            }
738 738
 
739
-	    }
739
+        }
740 740
 
741
-		require("sugar_version.php");
742
-		require('config.php');
743
-		global $sugar_config;
741
+        require("sugar_version.php");
742
+        require('config.php');
743
+        global $sugar_config;
744 744
 
745
-		require("{$instanceUpgradePath}/sugar_version.php");
746
-		if(!rebuildConfigFile($sugar_config, $sugar_version)) {
747
-			logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
748
-			$errors[] = 'Could not write config.php!';
749
-		}
750
-		checkConfigForPermissions();
745
+        require("{$instanceUpgradePath}/sugar_version.php");
746
+        if(!rebuildConfigFile($sugar_config, $sugar_version)) {
747
+            logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
748
+            $errors[] = 'Could not write config.php!';
749
+        }
750
+        checkConfigForPermissions();
751 751
 
752
-    	// clear out the theme cache
753
-		if(!class_exists('SugarThemeRegistry')){
754
-		    require_once($newtemplate_path . '/include/SugarTheme/SugarTheme.php');
755
-		}
756
-		SugarThemeRegistry::buildRegistry();
757
-		SugarThemeRegistry::clearAllCaches();
752
+        // clear out the theme cache
753
+        if(!class_exists('SugarThemeRegistry')){
754
+            require_once($newtemplate_path . '/include/SugarTheme/SugarTheme.php');
755
+        }
756
+        SugarThemeRegistry::buildRegistry();
757
+        SugarThemeRegistry::clearAllCaches();
758 758
 
759
-		// re-minify the JS source files
760
-		$_REQUEST['root_directory'] = getcwd();
761
-		$_REQUEST['js_rebuild_concat'] = 'rebuild';
762
-		require_once($newtemplate_path . '/jssource/minify.php');
759
+        // re-minify the JS source files
760
+        $_REQUEST['root_directory'] = getcwd();
761
+        $_REQUEST['js_rebuild_concat'] = 'rebuild';
762
+        require_once($newtemplate_path . '/jssource/minify.php');
763 763
 
764
-		//as last step, rebuild the language files and rebuild relationships
765
-		/*
764
+        //as last step, rebuild the language files and rebuild relationships
765
+        /*
766 766
 		if(file_exists($newtemplate_path.'/modules/Administration/RebuildJSLang.php')) {
767 767
 			logThis("begin rebuilding js language files. via ".$newtemplate_path.'/modules/Administration/RebuildJSLang.php', $path);
768 768
 			include($newtemplate_path.'/modules/Administration/RebuildJSLang.php');
@@ -779,52 +779,52 @@  discard block
 block discarded – undo
779 779
 if(isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])){
780 780
     if (version_compare($_SESSION['current_db_version'], $_SESSION['target_db_version'], '='))
781 781
     {
782
-	    $_REQUEST['upgradeWizard'] = true;
783
-	    ob_start();
784
-		include('include/Smarty/internals/core.write_file.php');
785
-		ob_end_clean();
786
-	 	$db =& DBManagerFactory::getInstance();
787
-		if($ce_to_pro_ent){
788
-	        //Also set license information
789
-	        $admin = new Administration();
790
-			$category = 'license';
791
-			$value = 0;
792
-			$admin->saveSetting($category, 'users', $value);
793
-			$key = array('num_lic_oc','key','expire_date');
794
-			$value = '';
795
-			foreach($key as $k){
796
-				$admin->saveSetting($category, $k, $value);
797
-			}
798
-		}
799
-	}
782
+        $_REQUEST['upgradeWizard'] = true;
783
+        ob_start();
784
+        include('include/Smarty/internals/core.write_file.php');
785
+        ob_end_clean();
786
+            $db =& DBManagerFactory::getInstance();
787
+        if($ce_to_pro_ent){
788
+            //Also set license information
789
+            $admin = new Administration();
790
+            $category = 'license';
791
+            $value = 0;
792
+            $admin->saveSetting($category, 'users', $value);
793
+            $key = array('num_lic_oc','key','expire_date');
794
+            $value = '';
795
+            foreach($key as $k){
796
+                $admin->saveSetting($category, $k, $value);
797
+            }
798
+        }
799
+    }
800 800
 }
801 801
 
802 802
 set_upgrade_progress('end','done','end','done');
803 803
 
804 804
 if(file_exists($newtemplate_path . '/modules/Configurator/Configurator.php')){
805
-	set_upgrade_progress('configurator','in_progress');
806
-	require_once($newtemplate_path . '/include/utils/array_utils.php');
807
-	if(!class_exists('Configurator')){
808
-		require_once($newtemplate_path . '/modules/Configurator/Configurator.php');
809
-	}
810
-	$Configurator = new Configurator();
811
-	if(class_exists('Configurator')){
812
-		$Configurator->parseLoggerSettings();
813
-	}
814
-	set_upgrade_progress('configurator','done');
805
+    set_upgrade_progress('configurator','in_progress');
806
+    require_once($newtemplate_path . '/include/utils/array_utils.php');
807
+    if(!class_exists('Configurator')){
808
+        require_once($newtemplate_path . '/modules/Configurator/Configurator.php');
809
+    }
810
+    $Configurator = new Configurator();
811
+    if(class_exists('Configurator')){
812
+        $Configurator->parseLoggerSettings();
813
+    }
814
+    set_upgrade_progress('configurator','done');
815 815
 }
816 816
 
817 817
 //unset the logger previously instantiated
818 818
 if(file_exists($newtemplate_path . '/include/SugarLogger/LoggerManager.php')){
819
-	set_upgrade_progress('logger','in_progress');
820
-	if(!class_exists('LoggerManager')){
819
+    set_upgrade_progress('logger','in_progress');
820
+    if(!class_exists('LoggerManager')){
821 821
 
822
-	}
823
-	if(class_exists('LoggerManager')){
824
-		unset($GLOBALS['log']);
825
-		$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
826
-	}
827
-	set_upgrade_progress('logger','done');
822
+    }
823
+    if(class_exists('LoggerManager')){
824
+        unset($GLOBALS['log']);
825
+        $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
826
+    }
827
+    set_upgrade_progress('logger','done');
828 828
 }
829 829
 
830 830
 ///////////////////////////////////////////////////////////////////////////////
@@ -833,22 +833,22 @@  discard block
 block discarded – undo
833 833
 ob_end_clean();
834 834
 
835 835
 if(count($errors) > 0) {
836
-	foreach($errors as $error) {
837
-		logThis("****** SilentUpgrade ERROR: {$error}", $path);
838
-	}
839
-	echo "FAILED\n";
836
+    foreach($errors as $error) {
837
+        logThis("****** SilentUpgrade ERROR: {$error}", $path);
838
+    }
839
+    echo "FAILED\n";
840 840
 } else {
841
-	logThis("***** SilentUpgrade completed successfully.", $path);
842
-	echo "********************************************************************\n";
843
-	echo "*************************** SUCCESS*********************************\n";
844
-	echo "********************************************************************\n";
845
-	echo "******** If your pre-upgrade Leads data is not showing  ************\n";
846
-	echo "******** Or you see errors in detailview subpanels  ****************\n";
847
-	echo "************* In order to resolve them  ****************************\n";
848
-	echo "******** Log into application as Administrator  ********************\n";
849
-	echo "******** Go to Admin panel  ****************************************\n";
850
-	echo "******** Run Repair -> Rebuild Relationships  **********************\n";
851
-	echo "********************************************************************\n";
841
+    logThis("***** SilentUpgrade completed successfully.", $path);
842
+    echo "********************************************************************\n";
843
+    echo "*************************** SUCCESS*********************************\n";
844
+    echo "********************************************************************\n";
845
+    echo "******** If your pre-upgrade Leads data is not showing  ************\n";
846
+    echo "******** Or you see errors in detailview subpanels  ****************\n";
847
+    echo "************* In order to resolve them  ****************************\n";
848
+    echo "******** Log into application as Administrator  ********************\n";
849
+    echo "******** Go to Admin panel  ****************************************\n";
850
+    echo "******** Run Repair -> Rebuild Relationships  **********************\n";
851
+    echo "********************************************************************\n";
852 852
 }
853 853
 
854 854
 
Please login to merge, or discard this patch.
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 //// php.exe -f silentUpgrade.php [Path to Upgrade Package zip] [Path to Log file] [Path to Instance]
43 43
 //// See below the Usage for more details.
44 44
 /////////////////////////////////////////////////////////////////////////////////////////
45
-ini_set('memory_limit',-1);
45
+ini_set('memory_limit', -1);
46 46
 ///////////////////////////////////////////////////////////////////////////////
47 47
 ////	UTILITIES THAT MUST BE LOCAL :(
48 48
 //local function for clearing cache
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 	if ($current = @opendir($thedir)) {
51 51
 		while (false !== ($children = readdir($current))) {
52 52
 			if ($children != "." && $children != "..") {
53
-				if (is_dir($thedir . "/" . $children)) {
54
-					clearCacheSU($thedir . "/" . $children, $extension);
53
+				if (is_dir($thedir."/".$children)) {
54
+					clearCacheSU($thedir."/".$children, $extension);
55 55
 				}
56
-				elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
57
-					unlink($thedir . "/" . $children);
56
+				elseif (is_file($thedir."/".$children) && substr_count($children, $extension)) {
57
+					unlink($thedir."/".$children);
58 58
 				}
59 59
 			}
60 60
 		}
@@ -62,34 +62,34 @@  discard block
 block discarded – undo
62 62
  }
63 63
  //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
64 64
  //no found then adds default_permissions to the config file.
65
- function checkConfigForPermissions(){
66
-     if(file_exists(getcwd().'/config.php')){
65
+ function checkConfigForPermissions() {
66
+     if (file_exists(getcwd().'/config.php')) {
67 67
          require(getcwd().'/config.php');
68 68
      }
69 69
      global $sugar_config;
70
-     if(!isset($sugar_config['default_permissions'])){
71
-             $sugar_config['default_permissions'] = array (
70
+     if (!isset($sugar_config['default_permissions'])) {
71
+             $sugar_config['default_permissions'] = array(
72 72
                      'dir_mode' => 02770,
73 73
                      'file_mode' => 0660,
74 74
                      'user' => '',
75 75
                      'group' => '',
76 76
              );
77 77
          ksort($sugar_config);
78
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
78
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
79 79
         	//writing to the file
80 80
  		}
81 81
      }
82 82
 }
83
-function checkLoggerSettings(){
84
-	if(file_exists(getcwd().'/config.php')){
83
+function checkLoggerSettings() {
84
+	if (file_exists(getcwd().'/config.php')) {
85 85
          require(getcwd().'/config.php');
86 86
      }
87 87
     global $sugar_config;
88
-	if(!isset($sugar_config['logger'])){
89
-	    $sugar_config['logger'] =array (
88
+	if (!isset($sugar_config['logger'])) {
89
+	    $sugar_config['logger'] = array(
90 90
 			'level'=>'fatal',
91 91
 		    'file' =>
92
-		     array (
92
+		     array(
93 93
 		      'ext' => '.log',
94 94
 		      'name' => 'sugarcrm',
95 95
 		      'dateFormat' => '%c',
@@ -99,23 +99,23 @@  discard block
 block discarded – undo
99 99
 		    ),
100 100
 		  );
101 101
 		 ksort($sugar_config);
102
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
102
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
103 103
         	//writing to the file
104 104
  		}
105 105
 	 }
106 106
 }
107 107
 
108
-function checkResourceSettings(){
109
-	if(file_exists(getcwd().'/config.php')){
108
+function checkResourceSettings() {
109
+	if (file_exists(getcwd().'/config.php')) {
110 110
          require(getcwd().'/config.php');
111 111
      }
112 112
     global $sugar_config;
113
-	if(!isset($sugar_config['resource_management'])){
113
+	if (!isset($sugar_config['resource_management'])) {
114 114
 	  $sugar_config['resource_management'] =
115
-		  array (
115
+		  array(
116 116
 		    'special_query_limit' => 50000,
117 117
 		    'special_query_modules' =>
118
-		    array (
118
+		    array(
119 119
 		      0 => 'Reports',
120 120
 		      1 => 'Export',
121 121
 		      2 => 'Import',
@@ -125,22 +125,22 @@  discard block
 block discarded – undo
125 125
 		    'default_limit' => 1000,
126 126
 		  );
127 127
 		 ksort($sugar_config);
128
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
128
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
129 129
         	//writing to the file
130 130
  		}
131 131
 	}
132 132
 }
133 133
 
134
-function createMissingRels(){
135
-	$relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
136
-	foreach($relForObjects as $relObjName=>$relModName){
134
+function createMissingRels() {
135
+	$relForObjects = array('leads'=>'Leads', 'campaigns'=>'Campaigns', 'prospects'=>'Prospects');
136
+	foreach ($relForObjects as $relObjName=>$relModName) {
137 137
 		//assigned_user
138 138
 		$guid = create_guid();
139 139
 		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
140
-		$result= $GLOBALS['db']->query($query, true);
140
+		$result = $GLOBALS['db']->query($query, true);
141 141
 		$a = null;
142 142
 		$a = $GLOBALS['db']->fetchByAssoc($result);
143
-		if(!isset($a['id']) && empty($a['id']) ){
143
+		if (!isset($a['id']) && empty($a['id'])) {
144 144
 			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
145 145
 						VALUES ('{$guid}', '{$relObjName}_assigned_user','Users','users','id','{$relModName}','{$relObjName}','assigned_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
146 146
 			$GLOBALS['db']->query($qRel);
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 		//modified_user
149 149
 		$guid = create_guid();
150 150
 		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
151
-		$result= $GLOBALS['db']->query($query, true);
151
+		$result = $GLOBALS['db']->query($query, true);
152 152
 		$a = null;
153 153
 		$a = $GLOBALS['db']->fetchByAssoc($result);
154
-		if(!isset($a['id']) && empty($a['id']) ){
154
+		if (!isset($a['id']) && empty($a['id'])) {
155 155
 			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
156 156
 						VALUES ('{$guid}', '{$relObjName}_modified_user','Users','users','id','{$relModName}','{$relObjName}','modified_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
157 157
 			$GLOBALS['db']->query($qRel);
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 		//created_by
160 160
 		$guid = create_guid();
161 161
 		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
162
-		$result= $GLOBALS['db']->query($query, true);
162
+		$result = $GLOBALS['db']->query($query, true);
163 163
 		$a = null;
164 164
 		$a = $GLOBALS['db']->fetchByAssoc($result);
165
-    	if(!isset($a['id']) && empty($a['id']) ){
165
+    	if (!isset($a['id']) && empty($a['id'])) {
166 166
 			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
167 167
 						VALUES ('{$guid}', '{$relObjName}_created_by','Users','users','id','{$relModName}','{$relObjName}','created_by',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
168 168
 			$GLOBALS['db']->query($qRel);
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
  */
181 181
 function merge_passwordsetting($sugar_config, $sugar_version) {
182 182
     $passwordsetting_defaults = array(
183
-    'passwordsetting' => array (
183
+    'passwordsetting' => array(
184 184
         'SystemGeneratedPasswordON' => '',
185 185
         'generatepasswordtmpl' => '',
186 186
         'lostpasswordtmpl' => '',
@@ -192,18 +192,18 @@  discard block
 block discarded – undo
192 192
         'systexpirationtime' => '',
193 193
         'systexpirationtype' => '0',
194 194
         'systexpirationlogin' => '',
195
-        ) ,
195
+        ),
196 196
     );
197 197
 
198 198
 
199
-    $sugar_config = sugarArrayMerge($passwordsetting_defaults, $sugar_config );
199
+    $sugar_config = sugarArrayMerge($passwordsetting_defaults, $sugar_config);
200 200
 
201 201
     // need to override version with default no matter what
202 202
     $sugar_config['sugar_version'] = $sugar_version;
203 203
 
204
-    ksort( $sugar_config );
204
+    ksort($sugar_config);
205 205
 
206
-    if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
206
+    if (write_array_to_file("sugar_config", $sugar_config, "config.php")) {
207 207
         return true;
208 208
     }
209 209
     else {
@@ -212,17 +212,17 @@  discard block
 block discarded – undo
212 212
 }
213 213
 
214 214
 function addDefaultModuleRoles($defaultRoles = array()) {
215
-	foreach($defaultRoles as $roleName=>$role){
216
-        foreach($role as $category=>$actions){
217
-            foreach($actions as $name=>$access_override){
215
+	foreach ($defaultRoles as $roleName=>$role) {
216
+        foreach ($role as $category=>$actions) {
217
+            foreach ($actions as $name=>$access_override) {
218 218
                     $query = "SELECT * FROM acl_actions WHERE name='$name' AND category = '$category' AND acltype='$roleName' AND deleted=0 ";
219 219
 					$result = $GLOBALS['db']->query($query);
220 220
 					//only add if an action with that name and category don't exist
221
-					$row=$GLOBALS['db']->fetchByAssoc($result);
221
+					$row = $GLOBALS['db']->fetchByAssoc($result);
222 222
 					if ($row == null) {
223 223
 	                	$guid = create_guid();
224 224
 	                	$currdate = gmdate('Y-m-d H:i:s');
225
-	                	$query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
225
+	                	$query = "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
226 226
 						$GLOBALS['db']->query($query);
227 227
 	                }
228 228
             }
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 }
232 232
 
233
-function verifyArguments($argv,$usage_dce,$usage_regular){
233
+function verifyArguments($argv, $usage_dce, $usage_regular) {
234 234
     $upgradeType = '';
235 235
     $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
236
-    if(isset($argv[3])) {
237
-        if(is_dir($argv[3])) {
236
+    if (isset($argv[3])) {
237
+        if (is_dir($argv[3])) {
238 238
             $cwd = $argv[3];
239 239
             chdir($cwd);
240 240
         } else {
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
     }
246 246
 
247 247
     //check if this is an instance
248
-    if(is_file("{$cwd}/ini_setup.php")){
248
+    if (is_file("{$cwd}/ini_setup.php")) {
249 249
         // this is an instance
250 250
         $upgradeType = constant('DCE_INSTANCE');
251 251
         //now that this is dce instance we want to make sure that there are
252 252
         // 7 arguments
253
-        if(count($argv) < 7) {
253
+        if (count($argv) < 7) {
254 254
             echo "*******************************************************************************\n";
255 255
             echo "*** ERROR: Missing required parameters.  Received ".count($argv)." argument(s), require 7.\n";
256 256
             echo $usage_dce;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
             exit(1);
259 259
         }
260 260
         // this is an instance
261
-        if(!is_dir($argv[1])) { // valid directory . template path?
261
+        if (!is_dir($argv[1])) { // valid directory . template path?
262 262
             echo "*******************************************************************************\n";
263 263
             echo "*** ERROR: First argument must be a full path to the template. Got [ {$argv[1]} ].\n";
264 264
             echo $usage_dce;
@@ -266,18 +266,18 @@  discard block
 block discarded – undo
266 266
             exit(1);
267 267
         }
268 268
     }
269
-    else if(is_file("{$cwd}/include/entryPoint.php")) {
269
+    else if (is_file("{$cwd}/include/entryPoint.php")) {
270 270
         //this should be a regular sugar install
271 271
         $upgradeType = constant('SUGARCRM_INSTALL');
272 272
         //check if this is a valid zip file
273
-        if(!is_file($argv[1])) { // valid zip?
273
+        if (!is_file($argv[1])) { // valid zip?
274 274
             echo "*******************************************************************************\n";
275 275
             echo "*** ERROR: First argument must be a full path to the patch file. Got [ {$argv[1]} ].\n";
276 276
             echo $usage_regular;
277 277
             echo "FAILURE\n";
278 278
             exit(1);
279 279
         }
280
-        if(count($argv) < 5) {
280
+        if (count($argv) < 5) {
281 281
             echo "*******************************************************************************\n";
282 282
             echo "*** ERROR: Missing required parameters.  Received ".count($argv)." argument(s), require 5.\n";
283 283
             echo $usage_regular;
@@ -292,29 +292,29 @@  discard block
 block discarded – undo
292 292
         exit(1);
293 293
     }
294 294
 
295
-    if(isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')){
295
+    if (isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')) {
296 296
         require_once($argv[7].'SugarTemplateUtilties.php');
297 297
     }
298 298
 
299 299
     return $upgradeType;
300 300
 }
301 301
 
302
-function upgradeDCEFiles($argv,$instanceUpgradePath){
302
+function upgradeDCEFiles($argv, $instanceUpgradePath) {
303 303
 	//copy and update following files from upgrade package
304
-	$upgradeTheseFiles = array('cron.php','download.php','index.php','install.php','soap.php','sugar_version.php','vcal_server.php');
305
-	foreach($upgradeTheseFiles as $file){
304
+	$upgradeTheseFiles = array('cron.php', 'download.php', 'index.php', 'install.php', 'soap.php', 'sugar_version.php', 'vcal_server.php');
305
+	foreach ($upgradeTheseFiles as $file) {
306 306
 		$srcFile = clean_path("{$instanceUpgradePath}/$file");
307 307
 		$destFile = clean_path("{$argv[3]}/$file");
308
-		if(file_exists($srcFile)){
309
-			if(!is_dir(dirname($destFile))) {
308
+		if (file_exists($srcFile)) {
309
+			if (!is_dir(dirname($destFile))) {
310 310
 				mkdir_recursive(dirname($destFile)); // make sure the directory exists
311 311
 			}
312
-			copy_recursive($srcFile,$destFile);
312
+			copy_recursive($srcFile, $destFile);
313 313
 			$_GET['TEMPLATE_PATH'] = $destFile;
314 314
 			$_GET['CONVERT_FILE_ONLY'] = true;
315
-			if(!class_exists('TemplateConverter')){
315
+			if (!class_exists('TemplateConverter')) {
316 316
 				include($argv[7].'templateConverter.php');
317
-			}else{
317
+			} else {
318 318
 				TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
319 319
 			}
320 320
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
 
327 327
 
328
-function threeWayMerge(){
328
+function threeWayMerge() {
329 329
 	//using threeway merge apis
330 330
 }
331 331
 ////	END UTILITIES THAT MUST BE LOCAL :(
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 //End of #52872
340 340
 
341 341
 // only run from command line
342
-if(isset($_SERVER['HTTP_USER_AGENT'])) {
343
-	fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
342
+if (isset($_SERVER['HTTP_USER_AGENT'])) {
343
+	fwrite(STDERR, 'This utility may only be run from the command line or command prompt.');
344 344
 	exit(1);
345 345
 }
346 346
 //Clean_string cleans out any file  passed in as a parameter
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 
350 350
 ///////////////////////////////////////////////////////////////////////////////
351 351
 ////	USAGE
352
-$usage_dce =<<<eoq1
352
+$usage_dce = <<<eoq1
353 353
 Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance]
354 354
 
355 355
 On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 
371 371
 eoq1;
372 372
 
373
-$usage_regular =<<<eoq2
373
+$usage_regular = <<<eoq2
374 374
 Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance] [admin-user]
375 375
 
376 376
 On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 
393 393
 ///////////////////////////////////////////////////////////////////////////////
394 394
 ////	STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
395
-if(!defined('sugarEntry')) define('sugarEntry', true);
395
+if (!defined('sugarEntry')) define('sugarEntry', true);
396 396
 
397 397
 $_SESSION = array();
398 398
 $_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 global $cwd;
410 410
 $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
411 411
 
412
-$upgradeType = verifyArguments($argv,$usage_dce,$usage_regular);
412
+$upgradeType = verifyArguments($argv, $usage_dce, $usage_regular);
413 413
 
414 414
 ///////////////////////////////////////////////////////////////////////////////
415 415
 //////  Verify that all the arguments are appropriately placed////////////////
@@ -419,14 +419,14 @@  discard block
 block discarded – undo
419 419
 //$GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
420 420
 //require_once('/var/www/html/eddy/sugarnode/SugarTemplateUtilities.php');
421 421
 
422
-$path			= $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
422
+$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
423 423
 //$db				= &DBManagerFactory::getInstance();  //<---------
424 424
 
425 425
 
426 426
 //$UWstrings		= return_module_language('en_us', 'UpgradeWizard');
427 427
 //$adminStrings	= return_module_language('en_us', 'Administration');
428 428
 //$mod_strings	= array_merge($adminStrings, $UWstrings);
429
-$subdirs		= array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
429
+$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
430 430
 
431 431
 //$_REQUEST['zip_from_dir'] = $zip_from_dir;
432 432
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 $errors = array();
449 449
 
450 450
 
451
-if($upgradeType == constant('DCE_INSTANCE')){
451
+if ($upgradeType == constant('DCE_INSTANCE')) {
452 452
    	//$instanceUpgradePath = "{$argv[1]}/DCEUpgrade/{$zip_from_dir}";
453 453
    	//$instanceUpgradePath = "{$argv[1]}";
454 454
 	include ("ini_setup.php");
@@ -494,25 +494,25 @@  discard block
 block discarded – undo
494 494
     $isDCEInstance = true;
495 495
     $configOptions = $sugar_config['dbconfig'];
496 496
 
497
-	$GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
498
-	$db				= &DBManagerFactory::getInstance();
497
+	$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
498
+	$db = &DBManagerFactory::getInstance();
499 499
        		///////////////////////////////////////////////////////////////////////////////
500 500
 	////	MAKE SURE PATCH IS COMPATIBLE
501 501
 
502
-	if(is_file("{$argv[1]}/manifest.php")) {
502
+	if (is_file("{$argv[1]}/manifest.php")) {
503 503
 		// provides $manifest array
504 504
 		include("{$argv[1]}/manifest.php");
505 505
 	}
506 506
 	//If Instance then the files will be accessed from Template/DCEUpgrade folder
507 507
 	$zip_from_dir = '';
508
-    if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){
509
-	    $zip_from_dir   = $manifest['copy_files']['from_dir'];
508
+    if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
509
+	    $zip_from_dir = $manifest['copy_files']['from_dir'];
510 510
 	}
511 511
 
512 512
 	$instanceUpgradePath = "{$argv[1]}/{$zip_from_dir}";
513 513
 	$_SESSION['sugar_version_file'] = '';
514 514
 	$srcFile = clean_path("{$instanceUpgradePath}/sugar_version.php");
515
-	if(file_exists($srcFile)) {
515
+	if (file_exists($srcFile)) {
516 516
 	   $_SESSION['sugar_version_file'] = $srcFile;
517 517
 	}
518 518
 
@@ -520,9 +520,9 @@  discard block
 block discarded – undo
520 520
 	global $instancePath;
521 521
 	$instancePath = $instanceUpgradePath;
522 522
 	$_SESSION['instancePath'] = $instancePath;
523
-	if(file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")){
523
+	if (file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")) {
524 524
 		require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
525
-	} else{
525
+	} else {
526 526
 		require_once("{$newtemplate_path}/modules/UpgradeWizard/uw_utils.php");
527 527
 	}
528 528
 
@@ -532,8 +532,8 @@  discard block
 block discarded – undo
532 532
     //check for db upgrade
533 533
     //check exit on conflicts
534 534
     $skipDBUpgrade = 'no'; //default
535
-    if($argv[6] != null && !empty($argv[6])){
536
-    	if(strtolower($argv[6]) == 'yes'){
535
+    if ($argv[6] != null && !empty($argv[6])) {
536
+    	if (strtolower($argv[6]) == 'yes') {
537 537
     	  $skipDBUpgrade = 'yes'; //override
538 538
     	}
539 539
     }
@@ -543,12 +543,12 @@  discard block
 block discarded – undo
543 543
     global $path;
544 544
     $path = $argv[2];
545 545
 
546
-    if($skipDBUpgrade == 'no'){
546
+    if ($skipDBUpgrade == 'no') {
547 547
     	//upgrade the db
548 548
 	    ///////////////////////////////////////////////////////////////////////////////
549 549
 		////	HANDLE PREINSTALL SCRIPTS
550 550
 		$file = "{$argv[1]}/".constant('SUGARCRM_PRE_INSTALL_FILE');
551
-		if(is_file($file)) {
551
+		if (is_file($file)) {
552 552
 			include($file);
553 553
 			logThis('Running pre_install()...', $path);
554 554
 			pre_install();
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
 
559 559
         //run the 3-way merge
560
-        if(file_exists($newtemplate_path.'/modules/UpgradeWizard/SugarMerge/SugarMerge.php')){
560
+        if (file_exists($newtemplate_path.'/modules/UpgradeWizard/SugarMerge/SugarMerge.php')) {
561 561
             logThis('Running 3 way merge()...', $path);
562 562
             require_once($newtemplate_path.'/modules/UpgradeWizard/SugarMerge/SugarMerge.php');
563 563
             $merger = new SugarMerge($instanceUpgradePath, $argv[4].'/', $argv[3].'/custom');
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 
568 568
 		logThis('Starting post_install()...', $path);
569 569
 		$file = "{$argv[1]}/".constant('SUGARCRM_POST_INSTALL_FILE');
570
-		if(is_file($file)) {
570
+		if (is_file($file)) {
571 571
 		    include($file);
572 572
 			post_install();
573 573
 		}
@@ -590,14 +590,14 @@  discard block
 block discarded – undo
590 590
         logThis('Set default_max_tabs to 7', $path);
591 591
         $sugar_config['default_max_tabs'] = '7';
592 592
 
593
-        if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) {
593
+        if (!write_array_to_file("sugar_config", $sugar_config, "config.php")) {
594 594
             logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
595 595
             $errors[] = 'Could not write config.php!';
596 596
         }
597 597
 
598 598
         //check to see if there are any new files that need to be added to systems tab
599 599
         //retrieve old modules list
600
-        logThis('check to see if new modules exist',$path);
600
+        logThis('check to see if new modules exist', $path);
601 601
         $oldModuleList = array();
602 602
         $newModuleList = array();
603 603
         include($argv[4].'/include/modules.php');
@@ -624,18 +624,18 @@  discard block
 block discarded – undo
624 624
 		$GLOBALS['reload_vardefs'] = true;
625 625
 
626 626
 		foreach ($beanFiles as $bean => $file) {
627
-			if(file_exists($newtemplate_path . '/' . $file) && $bean != 'UpgradeHistory'){
627
+			if (file_exists($newtemplate_path.'/'.$file) && $bean != 'UpgradeHistory') {
628 628
 				unset($GLOBALS['dictionary'][$bean]);
629
-				require_once($newtemplate_path . '/' . $file);
629
+				require_once($newtemplate_path.'/'.$file);
630 630
 
631
-				$focus = new $bean ();
632
-				if(empty($focus->table_name) || isset($repairedTables[$focus->table_name])) {
631
+				$focus = new $bean();
632
+				if (empty($focus->table_name) || isset($repairedTables[$focus->table_name])) {
633 633
 				   continue;
634 634
 				}
635 635
 
636 636
 				if (($focus instanceOf SugarBean)) {
637 637
 					$sql = $db->repairTable($focus, true);
638
-					if(!empty($sql)) {
638
+					if (!empty($sql)) {
639 639
 			   		   logThis($sql, $path);
640 640
 			   		   $repairedTables[$focus->table_name] = true;
641 641
 					}
@@ -648,14 +648,14 @@  discard block
 block discarded – undo
648 648
 		foreach ($dictionary as $meta) {
649 649
 			$tablename = $meta['table'];
650 650
 
651
-			if(isset($repairedTables[$tablename])) {
651
+			if (isset($repairedTables[$tablename])) {
652 652
 			   continue;
653 653
 			}
654 654
 
655 655
 			$fielddefs = $meta['fields'];
656 656
 			$indices = $meta['indices'];
657 657
 			$sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
658
-			if(!empty($sql)) {
658
+			if (!empty($sql)) {
659 659
 			    logThis($sql, $path);
660 660
 			    $repairedTables[$tablename] = true;
661 661
 			}
@@ -672,39 +672,39 @@  discard block
 block discarded – undo
672 672
         $oldModuleList = $newTB->get_key_array($oldModuleList);
673 673
 
674 674
         //iterate through list and remove commonalities to get new modules
675
-        foreach ($newModuleList as $remove_mod){
676
-            if(in_array($remove_mod, $oldModuleList)){
675
+        foreach ($newModuleList as $remove_mod) {
676
+            if (in_array($remove_mod, $oldModuleList)) {
677 677
                 unset($newModuleList[$remove_mod]);
678 678
             }
679 679
         }
680 680
         //new modules list now has left over modules which are new to this install, so lets add them to the system tabs
681
-        logThis('new modules to add are '.var_export($newModuleList,true),$path);
681
+        logThis('new modules to add are '.var_export($newModuleList, true), $path);
682 682
 
683 683
         //grab the existing system tabs
684 684
         $tabs = $newTB->get_system_tabs();
685 685
 
686 686
         //add the new tabs to the array
687
-        foreach($newModuleList as $nm ){
687
+        foreach ($newModuleList as $nm) {
688 688
           $tabs[$nm] = $nm;
689 689
         }
690 690
 
691 691
         //now assign the modules to system tabs
692 692
         $newTB->set_system_tabs($tabs);
693
-        logThis('module tabs updated',$path);
693
+        logThis('module tabs updated', $path);
694 694
 
695 695
 
696 696
 
697
-	    if($ce_to_pro_ent){
697
+	    if ($ce_to_pro_ent) {
698 698
 	    	//add the global team if it does not exist
699 699
 			$globalteam = new Team();
700 700
 			$globalteam->retrieve('1');
701 701
 			include($newtemplate_path.'/modules/Administration/language/en_us.lang.php');
702
-			if(isset($globalteam->name)){
702
+			if (isset($globalteam->name)) {
703 703
 
704 704
 			   echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>';
705 705
 			   logThis(" Finish Building private teams", $path);
706 706
 
707
-			}else{
707
+			} else {
708 708
 			   $globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team);
709 709
 			}
710 710
 
@@ -719,20 +719,20 @@  discard block
 block discarded – undo
719 719
 		    logThis(" Finish Building the team_set and team_sets_teams", $path);
720 720
 
721 721
 		    //upgrade teams
722
-			if(file_exists($newtemplate_path.'/modules/Administration/upgradeTeams.php')) {
722
+			if (file_exists($newtemplate_path.'/modules/Administration/upgradeTeams.php')) {
723 723
 				logThis(" Start {$newtemplate_path}/modules/Administration/upgradeTeams.php", $path);
724 724
 				include($newtemplate_path.'/modules/Administration/upgradeTeams.php');
725 725
 				logThis(" Finish {$newtemplate_path}/modules/Administration/upgradeTeams.php", $path);
726 726
 
727 727
 				//update the users records to have default team
728
-				logThis('running query to populate default_team on users table',$path);
728
+				logThis('running query to populate default_team on users table', $path);
729 729
 				$GLOBALS['db']->query("update users set default_team = (select teams.id from teams where teams.name = concat('(',users.user_name, ')') or team.associated_user_id = users.id)");
730 730
 
731 731
 			}
732 732
 
733 733
 			//run upgrade script for dashlets to include sales/marketing
734
-			if(function_exists('upgradeDashletsForSalesAndMarketing')){
735
-	           logThis('calling upgradeDashlets script',$path);
734
+			if (function_exists('upgradeDashletsForSalesAndMarketing')) {
735
+	           logThis('calling upgradeDashlets script', $path);
736 736
 			   upgradeDashletsForSalesAndMarketing();
737 737
 			}
738 738
 
@@ -743,15 +743,15 @@  discard block
 block discarded – undo
743 743
 		global $sugar_config;
744 744
 
745 745
 		require("{$instanceUpgradePath}/sugar_version.php");
746
-		if(!rebuildConfigFile($sugar_config, $sugar_version)) {
746
+		if (!rebuildConfigFile($sugar_config, $sugar_version)) {
747 747
 			logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
748 748
 			$errors[] = 'Could not write config.php!';
749 749
 		}
750 750
 		checkConfigForPermissions();
751 751
 
752 752
     	// clear out the theme cache
753
-		if(!class_exists('SugarThemeRegistry')){
754
-		    require_once($newtemplate_path . '/include/SugarTheme/SugarTheme.php');
753
+		if (!class_exists('SugarThemeRegistry')) {
754
+		    require_once($newtemplate_path.'/include/SugarTheme/SugarTheme.php');
755 755
 		}
756 756
 		SugarThemeRegistry::buildRegistry();
757 757
 		SugarThemeRegistry::clearAllCaches();
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 		// re-minify the JS source files
760 760
 		$_REQUEST['root_directory'] = getcwd();
761 761
 		$_REQUEST['js_rebuild_concat'] = 'rebuild';
762
-		require_once($newtemplate_path . '/jssource/minify.php');
762
+		require_once($newtemplate_path.'/jssource/minify.php');
763 763
 
764 764
 		//as last step, rebuild the language files and rebuild relationships
765 765
 		/*
@@ -776,55 +776,55 @@  discard block
 block discarded – undo
776 776
 
777 777
 
778 778
 //Also set the tracker settings if  flavor conversion ce->pro or ce->ent
779
-if(isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])){
779
+if (isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])) {
780 780
     if (version_compare($_SESSION['current_db_version'], $_SESSION['target_db_version'], '='))
781 781
     {
782 782
 	    $_REQUEST['upgradeWizard'] = true;
783 783
 	    ob_start();
784 784
 		include('include/Smarty/internals/core.write_file.php');
785 785
 		ob_end_clean();
786
-	 	$db =& DBManagerFactory::getInstance();
787
-		if($ce_to_pro_ent){
786
+	 	$db = & DBManagerFactory::getInstance();
787
+		if ($ce_to_pro_ent) {
788 788
 	        //Also set license information
789 789
 	        $admin = new Administration();
790 790
 			$category = 'license';
791 791
 			$value = 0;
792 792
 			$admin->saveSetting($category, 'users', $value);
793
-			$key = array('num_lic_oc','key','expire_date');
793
+			$key = array('num_lic_oc', 'key', 'expire_date');
794 794
 			$value = '';
795
-			foreach($key as $k){
795
+			foreach ($key as $k) {
796 796
 				$admin->saveSetting($category, $k, $value);
797 797
 			}
798 798
 		}
799 799
 	}
800 800
 }
801 801
 
802
-set_upgrade_progress('end','done','end','done');
802
+set_upgrade_progress('end', 'done', 'end', 'done');
803 803
 
804
-if(file_exists($newtemplate_path . '/modules/Configurator/Configurator.php')){
805
-	set_upgrade_progress('configurator','in_progress');
806
-	require_once($newtemplate_path . '/include/utils/array_utils.php');
807
-	if(!class_exists('Configurator')){
808
-		require_once($newtemplate_path . '/modules/Configurator/Configurator.php');
804
+if (file_exists($newtemplate_path.'/modules/Configurator/Configurator.php')) {
805
+	set_upgrade_progress('configurator', 'in_progress');
806
+	require_once($newtemplate_path.'/include/utils/array_utils.php');
807
+	if (!class_exists('Configurator')) {
808
+		require_once($newtemplate_path.'/modules/Configurator/Configurator.php');
809 809
 	}
810 810
 	$Configurator = new Configurator();
811
-	if(class_exists('Configurator')){
811
+	if (class_exists('Configurator')) {
812 812
 		$Configurator->parseLoggerSettings();
813 813
 	}
814
-	set_upgrade_progress('configurator','done');
814
+	set_upgrade_progress('configurator', 'done');
815 815
 }
816 816
 
817 817
 //unset the logger previously instantiated
818
-if(file_exists($newtemplate_path . '/include/SugarLogger/LoggerManager.php')){
819
-	set_upgrade_progress('logger','in_progress');
820
-	if(!class_exists('LoggerManager')){
818
+if (file_exists($newtemplate_path.'/include/SugarLogger/LoggerManager.php')) {
819
+	set_upgrade_progress('logger', 'in_progress');
820
+	if (!class_exists('LoggerManager')) {
821 821
 
822 822
 	}
823
-	if(class_exists('LoggerManager')){
823
+	if (class_exists('LoggerManager')) {
824 824
 		unset($GLOBALS['log']);
825 825
 		$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
826 826
 	}
827
-	set_upgrade_progress('logger','done');
827
+	set_upgrade_progress('logger', 'done');
828 828
 }
829 829
 
830 830
 ///////////////////////////////////////////////////////////////////////////////
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 $phpErrors = ob_get_contents();
833 833
 ob_end_clean();
834 834
 
835
-if(count($errors) > 0) {
836
-	foreach($errors as $error) {
835
+if (count($errors) > 0) {
836
+	foreach ($errors as $error) {
837 837
 		logThis("****** SilentUpgrade ERROR: {$error}", $path);
838 838
 	}
839 839
 	echo "FAILED\n";
Please login to merge, or discard this patch.
Braces   +9 added lines, -11 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@  discard block
 block discarded – undo
52 52
 			if ($children != "." && $children != "..") {
53 53
 				if (is_dir($thedir . "/" . $children)) {
54 54
 					clearCacheSU($thedir . "/" . $children, $extension);
55
-				}
56
-				elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
55
+				} elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
57 56
 					unlink($thedir . "/" . $children);
58 57
 				}
59 58
 			}
@@ -205,8 +204,7 @@  discard block
 block discarded – undo
205 204
 
206 205
     if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
207 206
         return true;
208
-    }
209
-    else {
207
+    } else {
210 208
         return false;
211 209
     }
212 210
 }
@@ -265,8 +263,7 @@  discard block
 block discarded – undo
265 263
             echo "FAILURE\n";
266 264
             exit(1);
267 265
         }
268
-    }
269
-    else if(is_file("{$cwd}/include/entryPoint.php")) {
266
+    } else if(is_file("{$cwd}/include/entryPoint.php")) {
270 267
         //this should be a regular sugar install
271 268
         $upgradeType = constant('SUGARCRM_INSTALL');
272 269
         //check if this is a valid zip file
@@ -284,8 +281,7 @@  discard block
 block discarded – undo
284 281
             echo "FAILURE\n";
285 282
             exit(1);
286 283
         }
287
-    }
288
-    else {
284
+    } else {
289 285
         //this should be a regular sugar install
290 286
         echo "*******************************************************************************\n";
291 287
         echo "*** ERROR: Tried to execute in a non-SugarCRM root directory.\n";
@@ -314,7 +310,7 @@  discard block
 block discarded – undo
314 310
 			$_GET['CONVERT_FILE_ONLY'] = true;
315 311
 			if(!class_exists('TemplateConverter')){
316 312
 				include($argv[7].'templateConverter.php');
317
-			}else{
313
+			} else{
318 314
 				TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
319 315
 			}
320 316
 
@@ -392,7 +388,9 @@  discard block
 block discarded – undo
392 388
 
393 389
 ///////////////////////////////////////////////////////////////////////////////
394 390
 ////	STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
395
-if(!defined('sugarEntry')) define('sugarEntry', true);
391
+if(!defined('sugarEntry')) {
392
+    define('sugarEntry', true);
393
+}
396 394
 
397 395
 $_SESSION = array();
398 396
 $_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
@@ -704,7 +702,7 @@  discard block
 block discarded – undo
704 702
 			   echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>';
705 703
 			   logThis(" Finish Building private teams", $path);
706 704
 
707
-			}else{
705
+			} else{
708 706
 			   $globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team);
709 707
 			}
710 708
 
Please login to merge, or discard this patch.
modules/UpgradeWizard/silentUpgrade_dce_step1.php 3 patches
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -46,151 +46,151 @@  discard block
 block discarded – undo
46 46
 ///////////////////////////////////////////////////////////////////////////////
47 47
 ////	UTILITIES THAT MUST BE LOCAL :(
48 48
 function prepSystemForUpgradeSilent() {
49
-	global $subdirs;
50
-	global $cwd;
51
-	global $sugar_config;
52
-
53
-	// make sure dirs exist
54
-	foreach($subdirs as $subdir) {
55
-		if(!is_dir("upload://upgrades/{$subdir}")) {
56
-	    	mkdir_recursive("upload://upgrades/{$subdir}");
57
-		}
58
-	}
49
+    global $subdirs;
50
+    global $cwd;
51
+    global $sugar_config;
52
+
53
+    // make sure dirs exist
54
+    foreach($subdirs as $subdir) {
55
+        if(!is_dir("upload://upgrades/{$subdir}")) {
56
+            mkdir_recursive("upload://upgrades/{$subdir}");
57
+        }
58
+    }
59 59
 }
60 60
 
61 61
 //local function for clearing cache
62 62
 function clearCacheSU($thedir, $extension) {
63
-	if ($current = @opendir($thedir)) {
64
-		while (false !== ($children = readdir($current))) {
65
-			if ($children != "." && $children != "..") {
66
-				if (is_dir($thedir . "/" . $children)) {
67
-					clearCacheSU($thedir . "/" . $children, $extension);
68
-				}
69
-				elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
70
-					unlink($thedir . "/" . $children);
71
-				}
72
-			}
73
-		}
74
-	}
75
- }
76
- //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
77
- //no found then adds default_permissions to the config file.
78
- function checkConfigForPermissions(){
79
-     if(file_exists(getcwd().'/config.php')){
80
-         require(getcwd().'/config.php');
81
-     }
82
-     global $sugar_config;
83
-     if(!isset($sugar_config['default_permissions'])){
84
-             $sugar_config['default_permissions'] = array (
85
-                     'dir_mode' => 02770,
86
-                     'file_mode' => 0660,
87
-                     'user' => '',
88
-                     'group' => '',
89
-             );
90
-         ksort($sugar_config);
91
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
92
-        	//writing to the file
93
- 		}
94
-     }
63
+    if ($current = @opendir($thedir)) {
64
+        while (false !== ($children = readdir($current))) {
65
+            if ($children != "." && $children != "..") {
66
+                if (is_dir($thedir . "/" . $children)) {
67
+                    clearCacheSU($thedir . "/" . $children, $extension);
68
+                }
69
+                elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
70
+                    unlink($thedir . "/" . $children);
71
+                }
72
+            }
73
+        }
74
+    }
75
+    }
76
+    //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
77
+    //no found then adds default_permissions to the config file.
78
+    function checkConfigForPermissions(){
79
+        if(file_exists(getcwd().'/config.php')){
80
+            require(getcwd().'/config.php');
81
+        }
82
+        global $sugar_config;
83
+        if(!isset($sugar_config['default_permissions'])){
84
+                $sugar_config['default_permissions'] = array (
85
+                        'dir_mode' => 02770,
86
+                        'file_mode' => 0660,
87
+                        'user' => '',
88
+                        'group' => '',
89
+                );
90
+            ksort($sugar_config);
91
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
92
+            //writing to the file
93
+            }
94
+        }
95 95
 }
96 96
 function checkLoggerSettings(){
97
-	if(file_exists(getcwd().'/config.php')){
98
-         require(getcwd().'/config.php');
99
-     }
97
+    if(file_exists(getcwd().'/config.php')){
98
+            require(getcwd().'/config.php');
99
+        }
100 100
     global $sugar_config;
101
-	if(!isset($sugar_config['logger'])){
102
-	    $sugar_config['logger'] =array (
103
-			'level'=>'fatal',
104
-		    'file' =>
105
-		     array (
106
-		      'ext' => '.log',
107
-		      'name' => 'sugarcrm',
108
-		      'dateFormat' => '%c',
109
-		      'maxSize' => '10MB',
110
-		      'maxLogs' => 10,
111
-		      'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
112
-		    ),
113
-		  );
114
-		 ksort($sugar_config);
115
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
116
-        	//writing to the file
117
- 		}
118
-	 }
101
+    if(!isset($sugar_config['logger'])){
102
+        $sugar_config['logger'] =array (
103
+            'level'=>'fatal',
104
+            'file' =>
105
+                array (
106
+                'ext' => '.log',
107
+                'name' => 'sugarcrm',
108
+                'dateFormat' => '%c',
109
+                'maxSize' => '10MB',
110
+                'maxLogs' => 10,
111
+                'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
112
+            ),
113
+            );
114
+            ksort($sugar_config);
115
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
116
+            //writing to the file
117
+            }
118
+        }
119 119
 }
120 120
 
121 121
 function checkResourceSettings(){
122
-	if(file_exists(getcwd().'/config.php')){
123
-         require(getcwd().'/config.php');
124
-     }
122
+    if(file_exists(getcwd().'/config.php')){
123
+            require(getcwd().'/config.php');
124
+        }
125 125
     global $sugar_config;
126
-	if(!isset($sugar_config['resource_management'])){
127
-	  $sugar_config['resource_management'] =
128
-		  array (
129
-		    'special_query_limit' => 50000,
130
-		    'special_query_modules' =>
131
-		    array (
132
-		      0 => 'Reports',
133
-		      1 => 'Export',
134
-		      2 => 'Import',
135
-		      3 => 'Administration',
136
-		      4 => 'Sync',
137
-		    ),
138
-		    'default_limit' => 1000,
139
-		  );
140
-		 ksort($sugar_config);
141
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
142
-        	//writing to the file
143
- 		}
144
-	}
126
+    if(!isset($sugar_config['resource_management'])){
127
+        $sugar_config['resource_management'] =
128
+            array (
129
+            'special_query_limit' => 50000,
130
+            'special_query_modules' =>
131
+            array (
132
+                0 => 'Reports',
133
+                1 => 'Export',
134
+                2 => 'Import',
135
+                3 => 'Administration',
136
+                4 => 'Sync',
137
+            ),
138
+            'default_limit' => 1000,
139
+            );
140
+            ksort($sugar_config);
141
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
142
+            //writing to the file
143
+            }
144
+    }
145 145
 }
146 146
 
147 147
 
148 148
 //rebuild all relationships...
149 149
 function rebuildRelations($pre_path = ''){
150
-	$_REQUEST['silent'] = true;
151
-	include($pre_path.'modules/Administration/RebuildRelationship.php');
152
-	 $_REQUEST['upgradeWizard'] = true;
153
-	 include($pre_path.'modules/ACL/install_actions.php');
150
+    $_REQUEST['silent'] = true;
151
+    include($pre_path.'modules/Administration/RebuildRelationship.php');
152
+        $_REQUEST['upgradeWizard'] = true;
153
+        include($pre_path.'modules/ACL/install_actions.php');
154 154
 }
155 155
 
156 156
 function createMissingRels(){
157
-	$relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
158
-	foreach($relForObjects as $relObjName=>$relModName){
159
-		//assigned_user
160
-		$guid = create_guid();
161
-		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
162
-		$result= $GLOBALS['db']->query($query, true);
163
-		$a = null;
164
-		$a = $GLOBALS['db']->fetchByAssoc($result);
165
-		if(!isset($a['id']) && empty($a['id']) ){
166
-			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
157
+    $relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
158
+    foreach($relForObjects as $relObjName=>$relModName){
159
+        //assigned_user
160
+        $guid = create_guid();
161
+        $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
162
+        $result= $GLOBALS['db']->query($query, true);
163
+        $a = null;
164
+        $a = $GLOBALS['db']->fetchByAssoc($result);
165
+        if(!isset($a['id']) && empty($a['id']) ){
166
+            $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
167 167
 						VALUES ('{$guid}', '{$relObjName}_assigned_user','Users','users','id','{$relModName}','{$relObjName}','assigned_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
168
-			$GLOBALS['db']->query($qRel);
169
-		}
170
-		//modified_user
171
-		$guid = create_guid();
172
-		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
173
-		$result= $GLOBALS['db']->query($query, true);
174
-		$a = null;
175
-		$a = $GLOBALS['db']->fetchByAssoc($result);
176
-		if(!isset($a['id']) && empty($a['id']) ){
177
-			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
168
+            $GLOBALS['db']->query($qRel);
169
+        }
170
+        //modified_user
171
+        $guid = create_guid();
172
+        $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
173
+        $result= $GLOBALS['db']->query($query, true);
174
+        $a = null;
175
+        $a = $GLOBALS['db']->fetchByAssoc($result);
176
+        if(!isset($a['id']) && empty($a['id']) ){
177
+            $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
178 178
 						VALUES ('{$guid}', '{$relObjName}_modified_user','Users','users','id','{$relModName}','{$relObjName}','modified_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
179
-			$GLOBALS['db']->query($qRel);
180
-		}
181
-		//created_by
182
-		$guid = create_guid();
183
-		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
184
-		$result= $GLOBALS['db']->query($query, true);
185
-		$a = null;
186
-		$a = $GLOBALS['db']->fetchByAssoc($result);
187
-    	if(!isset($a['id']) && empty($a['id']) ){
188
-			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
179
+            $GLOBALS['db']->query($qRel);
180
+        }
181
+        //created_by
182
+        $guid = create_guid();
183
+        $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
184
+        $result= $GLOBALS['db']->query($query, true);
185
+        $a = null;
186
+        $a = $GLOBALS['db']->fetchByAssoc($result);
187
+        if(!isset($a['id']) && empty($a['id']) ){
188
+            $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
189 189
 						VALUES ('{$guid}', '{$relObjName}_created_by','Users','users','id','{$relModName}','{$relObjName}','created_by',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
190
-			$GLOBALS['db']->query($qRel);
191
-    	}
192
-	}
193
-	//Also add tracker perf relationship
190
+            $GLOBALS['db']->query($qRel);
191
+        }
192
+    }
193
+    //Also add tracker perf relationship
194 194
 }
195 195
 
196 196
 
@@ -234,22 +234,22 @@  discard block
 block discarded – undo
234 234
 }
235 235
 
236 236
 function addDefaultModuleRoles($defaultRoles = array()) {
237
-	foreach($defaultRoles as $roleName=>$role){
237
+    foreach($defaultRoles as $roleName=>$role){
238 238
         foreach($role as $category=>$actions){
239 239
             foreach($actions as $name=>$access_override){
240 240
                     $query = "SELECT * FROM acl_actions WHERE name='$name' AND category = '$category' AND acltype='$roleName' AND deleted=0 ";
241
-					$result = $GLOBALS['db']->query($query);
242
-					//only add if an action with that name and category don't exist
243
-					$row=$GLOBALS['db']->fetchByAssoc($result);
244
-					if ($row == null) {
245
-	                	$guid = create_guid();
246
-	                	$currdate = gmdate($GLOBALS['timedate']->get_db_date_time_format());
247
-	                	$query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
248
-						$GLOBALS['db']->query($query);
249
-	                }
241
+                    $result = $GLOBALS['db']->query($query);
242
+                    //only add if an action with that name and category don't exist
243
+                    $row=$GLOBALS['db']->fetchByAssoc($result);
244
+                    if ($row == null) {
245
+                        $guid = create_guid();
246
+                        $currdate = gmdate($GLOBALS['timedate']->get_db_date_time_format());
247
+                        $query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
248
+                        $GLOBALS['db']->query($query);
249
+                    }
250 250
             }
251 251
         }
252
-	}
252
+    }
253 253
 }
254 254
 
255 255
 function verifyArguments($argv,$usage_dce,$usage_regular){
@@ -322,33 +322,33 @@  discard block
 block discarded – undo
322 322
 }
323 323
 
324 324
 function upgradeDCEFiles($argv,$instanceUpgradePath){
325
-	//copy and update following files from upgrade package
326
-	$upgradeTheseFiles = array('cron.php','download.php','index.php','install.php','soap.php','sugar_version.php','vcal_server.php');
327
-	foreach($upgradeTheseFiles as $file){
328
-		$srcFile = clean_path("{$instanceUpgradePath}/$file");
329
-		$destFile = clean_path("{$argv[3]}/$file");
330
-		if(file_exists($srcFile)){
331
-			if(!is_dir(dirname($destFile))) {
332
-				mkdir_recursive(dirname($destFile)); // make sure the directory exists
333
-			}
334
-			copy_recursive($srcFile,$destFile);
335
-			$_GET['TEMPLATE_PATH'] = $destFile;
336
-			$_GET['CONVERT_FILE_ONLY'] = true;
337
-			if(!class_exists('TemplateConverter')){
338
-				include($argv[7].'templateConverter.php');
339
-			}else{
340
-				TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
341
-			}
342
-
343
-
344
-		}
345
-	}
325
+    //copy and update following files from upgrade package
326
+    $upgradeTheseFiles = array('cron.php','download.php','index.php','install.php','soap.php','sugar_version.php','vcal_server.php');
327
+    foreach($upgradeTheseFiles as $file){
328
+        $srcFile = clean_path("{$instanceUpgradePath}/$file");
329
+        $destFile = clean_path("{$argv[3]}/$file");
330
+        if(file_exists($srcFile)){
331
+            if(!is_dir(dirname($destFile))) {
332
+                mkdir_recursive(dirname($destFile)); // make sure the directory exists
333
+            }
334
+            copy_recursive($srcFile,$destFile);
335
+            $_GET['TEMPLATE_PATH'] = $destFile;
336
+            $_GET['CONVERT_FILE_ONLY'] = true;
337
+            if(!class_exists('TemplateConverter')){
338
+                include($argv[7].'templateConverter.php');
339
+            }else{
340
+                TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
341
+            }
342
+
343
+
344
+        }
345
+    }
346 346
 }
347 347
 
348 348
 
349 349
 
350 350
 function threeWayMerge(){
351
-	//using threeway merge apis
351
+    //using threeway merge apis
352 352
 }
353 353
 ////	END UTILITIES THAT MUST BE LOCAL :(
354 354
 ///////////////////////////////////////////////////////////////////////////////
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
 
363 363
 // only run from command line
364 364
 if(isset($_SERVER['HTTP_USER_AGENT'])) {
365
-	fwrite(STDERR, 'This utility may only be run from the command line or command prompt.');
366
-	exit(1);
365
+    fwrite(STDERR, 'This utility may only be run from the command line or command prompt.');
366
+    exit(1);
367 367
 }
368 368
 //Clean_string cleans out any file  passed in as a parameter
369 369
 $_SERVER['PHP_SELF'] = 'silentUpgrade.php';
@@ -471,144 +471,144 @@  discard block
 block discarded – undo
471 471
 
472 472
 
473 473
 if($upgradeType == constant('DCE_INSTANCE')){
474
-   	//$instanceUpgradePath = "{$argv[1]}/DCEUpgrade/{$zip_from_dir}";
475
-   	//$instanceUpgradePath = "{$argv[1]}";
476
-	include ("ini_setup.php");
474
+        //$instanceUpgradePath = "{$argv[1]}/DCEUpgrade/{$zip_from_dir}";
475
+        //$instanceUpgradePath = "{$argv[1]}";
476
+    include ("ini_setup.php");
477 477
 
478
-	//get new template path for use in later processing
478
+    //get new template path for use in later processing
479 479
     $dceupgrade_pos = strpos($argv[1], '/DCEUpgrade');
480 480
     $newtemplate_path = substr($argv[1], 0, $dceupgrade_pos);
481 481
 
482
-	require("{$argv[4]}/sugar_version.php");
483
-	global $sugar_version;
484
-
485
-	//load up entrypoint from original template
486
-   	require_once("{$argv[4]}/include/entryPoint.php");
487
-	require_once("{$argv[4]}/include/utils/zip_utils.php");
488
-	require_once("{$argv[4]}/modules/Administration/UpgradeHistory.php");
489
-	// We need to run the silent upgrade as the admin user,
490
-	global $current_user;
491
-	$current_user = new User();
492
-	$current_user->retrieve('1');
493
-
494
-	//This is DCE instance
495
-      global $sugar_config;
496
-      global $sugar_version;
482
+    require("{$argv[4]}/sugar_version.php");
483
+    global $sugar_version;
484
+
485
+    //load up entrypoint from original template
486
+        require_once("{$argv[4]}/include/entryPoint.php");
487
+    require_once("{$argv[4]}/include/utils/zip_utils.php");
488
+    require_once("{$argv[4]}/modules/Administration/UpgradeHistory.php");
489
+    // We need to run the silent upgrade as the admin user,
490
+    global $current_user;
491
+    $current_user = new User();
492
+    $current_user->retrieve('1');
493
+
494
+    //This is DCE instance
495
+        global $sugar_config;
496
+        global $sugar_version;
497 497
 //    require_once("{$cwd}/sugar_version.php"); //provides instance version, flavor etc..
498
-     //provides instance version, flavor etc..
498
+        //provides instance version, flavor etc..
499 499
     $isDCEInstance = true;
500
-	prepSystemForUpgradeSilent();
501
-
502
-	/////retrieve admin user
503
-	$configOptions = $sugar_config['dbconfig'];
504
-
505
-	$GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
506
-	$db				= &DBManagerFactory::getInstance();
507
-       		///////////////////////////////////////////////////////////////////////////////
508
-	////	MAKE SURE PATCH IS COMPATIBLE
509
-
510
-	if(is_file("{$argv[1]}/manifest.php")) {
511
-		// provides $manifest array
512
-		include("{$argv[1]}/manifest.php");
513
-	}
514
-	//If Instance then the files will be accessed from Template/DCEUpgrade folder
515
-	$zip_from_dir = '';
500
+    prepSystemForUpgradeSilent();
501
+
502
+    /////retrieve admin user
503
+    $configOptions = $sugar_config['dbconfig'];
504
+
505
+    $GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
506
+    $db				= &DBManagerFactory::getInstance();
507
+                ///////////////////////////////////////////////////////////////////////////////
508
+    ////	MAKE SURE PATCH IS COMPATIBLE
509
+
510
+    if(is_file("{$argv[1]}/manifest.php")) {
511
+        // provides $manifest array
512
+        include("{$argv[1]}/manifest.php");
513
+    }
514
+    //If Instance then the files will be accessed from Template/DCEUpgrade folder
515
+    $zip_from_dir = '';
516 516
     if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){
517
-	    $zip_from_dir   = $manifest['copy_files']['from_dir'];
518
-	}
519
-	$instanceUpgradePath = "{$argv[1]}/{$zip_from_dir}";
520
-	global $instancePath;
521
-	$instancePath = $instanceUpgradePath;
522
-	$_SESSION['instancePath'] = $instancePath;
523
-	if(file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")){
524
-		require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
525
-	}
526
-	else{
527
-		require_once("{$argv[4]}/modules/UpgradeWizard/uw_utils.php");
528
-	}
517
+        $zip_from_dir   = $manifest['copy_files']['from_dir'];
518
+    }
519
+    $instanceUpgradePath = "{$argv[1]}/{$zip_from_dir}";
520
+    global $instancePath;
521
+    $instancePath = $instanceUpgradePath;
522
+    $_SESSION['instancePath'] = $instancePath;
523
+    if(file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")){
524
+        require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
525
+    }
526
+    else{
527
+        require_once("{$argv[4]}/modules/UpgradeWizard/uw_utils.php");
528
+    }
529 529
     if(function_exists('set_upgrade_vars')){
530
-		set_upgrade_vars();
530
+        set_upgrade_vars();
531
+    }
532
+    if(is_file("$argv[1]/manifest.php")) {
533
+        // provides $manifest array
534
+        //include("$instanceUpgradePath/manifest.php");
535
+        if(!isset($manifest)) {
536
+            fwrite(STDERR, "\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
537
+            exit(1);
538
+        } else {
539
+            $error = validate_manifest($manifest);
540
+            if(!empty($error)) {
541
+                $error = strip_tags(br2nl($error));
542
+                fwrite(STDERR,"\n{$error}\n\nFAILURE\n");
543
+                exit(1);
544
+            }
545
+        }
546
+    } else {
547
+        fwrite(STDERR, "\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
548
+        exit(1);
531 549
     }
532
-	if(is_file("$argv[1]/manifest.php")) {
533
-		// provides $manifest array
534
-		//include("$instanceUpgradePath/manifest.php");
535
-		if(!isset($manifest)) {
536
-		    fwrite(STDERR, "\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
537
-		    exit(1);
538
-		} else {
539
-			$error = validate_manifest($manifest);
540
-			if(!empty($error)) {
541
-				$error = strip_tags(br2nl($error));
542
-				fwrite(STDERR,"\n{$error}\n\nFAILURE\n");
543
-				exit(1);
544
-			}
545
-		}
546
-	} else {
547
-		fwrite(STDERR, "\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
548
-		exit(1);
549
-	}
550 550
 
551 551
     $ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt' || $manifest['name'] == 'SugarCE to SugarCorp' || $manifest['name'] == 'SugarCE to SugarUlt');
552
-	$_SESSION['upgrade_from_flavor'] = $manifest['name'];
552
+    $_SESSION['upgrade_from_flavor'] = $manifest['name'];
553 553
 
554
-	//get the latest uw_utils.php
554
+    //get the latest uw_utils.php
555 555
 //	require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
556 556
     logThis("*** SILENT DCE UPGRADE INITIATED.", $path);
557
-	logThis("*** UpgradeWizard Upgraded  ", $path);
558
-	$_SESSION['sugar_version_file'] = '';
559
-	$srcFile = clean_path("{$instanceUpgradePath}/sugar_version.php");
560
-	if(file_exists($srcFile)) {
561
-		logThis('Save the version file in session variable', $path);
562
-		$_SESSION['sugar_version_file'] = $srcFile;
563
-	}
557
+    logThis("*** UpgradeWizard Upgraded  ", $path);
558
+    $_SESSION['sugar_version_file'] = '';
559
+    $srcFile = clean_path("{$instanceUpgradePath}/sugar_version.php");
560
+    if(file_exists($srcFile)) {
561
+        logThis('Save the version file in session variable', $path);
562
+        $_SESSION['sugar_version_file'] = $srcFile;
563
+    }
564 564
 
565 565
 
566 566
 
567 567
     //check exit on conflicts
568 568
     $exitOnConflict = 'yes'; //default
569 569
     if($argv[5] != null && !empty($argv[5])){
570
-    	if(strtolower($argv[5]) == 'no'){
571
-    	  $exitOnConflict = 'no'; //override
572
-    	}
570
+        if(strtolower($argv[5]) == 'no'){
571
+            $exitOnConflict = 'no'; //override
572
+        }
573 573
     }
574 574
     if($exitOnConflict == 'yes'){
575
-    	$customFiles = array();
576
-    	$customFiles = findAllFiles(clean_path("{$argv[3]}/custom"), $customFiles);
577
-    	if($customFiles != null){
578
-    		logThis("*** ****************************  ****", $path);
579
-			logThis("*** START LOGGING CUSTOM FILES  ****", $path);
580
-			$existsCustomFile = false;
581
-			foreach($customFiles as $file) {
582
-			$srcFile = clean_path($file);
583
-			//$targetFile = clean_path(getcwd() . '/' . $srcFile);
584
-			    if (strpos($srcFile,".svn") !== false) {
585
-				  //do nothing
586
-			    }
587
-			    else{
588
-			     $existsCustomFile = true;
589
-			     //log the custom file in
590
-			     logThis($file, $path);
591
-			    }
592
-			}
593
-			logThis("*** END LOGGING CUSTOM FILES  ****", $path);
594
-			logThis("*** ****************************  ****", $path);
595
-			if($existsCustomFile){
596
-				echo 'Stop and Exit Upgrade. There are customized files. Take a look in the upgrade log';
597
-				logThis("Stop and Exit Upgrade. There are customized files. Take a look in the upgrade log", $path);
598
-				exit(1);
599
-			}
600
-			else{
601
-			    upgradeDCEFiles($argv,$instanceUpgradePath);
602
-			}
603
-    	}
604
-    	else{
605
-			   //copy and update following files from upgrade package
606
-				upgradeDCEFiles($argv,$instanceUpgradePath);
607
-		 }
575
+        $customFiles = array();
576
+        $customFiles = findAllFiles(clean_path("{$argv[3]}/custom"), $customFiles);
577
+        if($customFiles != null){
578
+            logThis("*** ****************************  ****", $path);
579
+            logThis("*** START LOGGING CUSTOM FILES  ****", $path);
580
+            $existsCustomFile = false;
581
+            foreach($customFiles as $file) {
582
+            $srcFile = clean_path($file);
583
+            //$targetFile = clean_path(getcwd() . '/' . $srcFile);
584
+                if (strpos($srcFile,".svn") !== false) {
585
+                    //do nothing
586
+                }
587
+                else{
588
+                    $existsCustomFile = true;
589
+                    //log the custom file in
590
+                    logThis($file, $path);
591
+                }
592
+            }
593
+            logThis("*** END LOGGING CUSTOM FILES  ****", $path);
594
+            logThis("*** ****************************  ****", $path);
595
+            if($existsCustomFile){
596
+                echo 'Stop and Exit Upgrade. There are customized files. Take a look in the upgrade log';
597
+                logThis("Stop and Exit Upgrade. There are customized files. Take a look in the upgrade log", $path);
598
+                exit(1);
599
+            }
600
+            else{
601
+                upgradeDCEFiles($argv,$instanceUpgradePath);
602
+            }
603
+        }
604
+        else{
605
+                //copy and update following files from upgrade package
606
+                upgradeDCEFiles($argv,$instanceUpgradePath);
607
+            }
608 608
     }
609 609
     else{
610
-	   //copy and update following files from upgrade package
611
-	   upgradeDCEFiles($argv,$instanceUpgradePath);
610
+        //copy and update following files from upgrade package
611
+        upgradeDCEFiles($argv,$instanceUpgradePath);
612 612
     }
613 613
 
614 614
     global $unzip_dir;
@@ -626,9 +626,9 @@  discard block
 block discarded – undo
626 626
 logThis("**** Potential PHP generated error messages: {$phpErrors}", $path);
627 627
 
628 628
 if(count($errors) > 0) {
629
-	foreach($errors as $error) {
630
-		logThis("****** SilentUpgrade ERROR: {$error}", $path);
631
-	}
632
-	echo "FAILED\n";
629
+    foreach($errors as $error) {
630
+        logThis("****** SilentUpgrade ERROR: {$error}", $path);
631
+    }
632
+    echo "FAILED\n";
633 633
 }
634 634
 ?>
635 635
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 //// php.exe -f silentUpgrade.php [Path to Upgrade Package zip] [Path to Log file] [Path to Instance]
43 43
 //// See below the Usage for more details.
44 44
 /////////////////////////////////////////////////////////////////////////////////////////
45
-ini_set('memory_limit',-1);
45
+ini_set('memory_limit', -1);
46 46
 ///////////////////////////////////////////////////////////////////////////////
47 47
 ////	UTILITIES THAT MUST BE LOCAL :(
48 48
 function prepSystemForUpgradeSilent() {
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	global $sugar_config;
52 52
 
53 53
 	// make sure dirs exist
54
-	foreach($subdirs as $subdir) {
55
-		if(!is_dir("upload://upgrades/{$subdir}")) {
54
+	foreach ($subdirs as $subdir) {
55
+		if (!is_dir("upload://upgrades/{$subdir}")) {
56 56
 	    	mkdir_recursive("upload://upgrades/{$subdir}");
57 57
 		}
58 58
 	}
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 	if ($current = @opendir($thedir)) {
64 64
 		while (false !== ($children = readdir($current))) {
65 65
 			if ($children != "." && $children != "..") {
66
-				if (is_dir($thedir . "/" . $children)) {
67
-					clearCacheSU($thedir . "/" . $children, $extension);
66
+				if (is_dir($thedir."/".$children)) {
67
+					clearCacheSU($thedir."/".$children, $extension);
68 68
 				}
69
-				elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
70
-					unlink($thedir . "/" . $children);
69
+				elseif (is_file($thedir."/".$children) && substr_count($children, $extension)) {
70
+					unlink($thedir."/".$children);
71 71
 				}
72 72
 			}
73 73
 		}
@@ -75,34 +75,34 @@  discard block
 block discarded – undo
75 75
  }
76 76
  //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
77 77
  //no found then adds default_permissions to the config file.
78
- function checkConfigForPermissions(){
79
-     if(file_exists(getcwd().'/config.php')){
78
+ function checkConfigForPermissions() {
79
+     if (file_exists(getcwd().'/config.php')) {
80 80
          require(getcwd().'/config.php');
81 81
      }
82 82
      global $sugar_config;
83
-     if(!isset($sugar_config['default_permissions'])){
84
-             $sugar_config['default_permissions'] = array (
83
+     if (!isset($sugar_config['default_permissions'])) {
84
+             $sugar_config['default_permissions'] = array(
85 85
                      'dir_mode' => 02770,
86 86
                      'file_mode' => 0660,
87 87
                      'user' => '',
88 88
                      'group' => '',
89 89
              );
90 90
          ksort($sugar_config);
91
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
91
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
92 92
         	//writing to the file
93 93
  		}
94 94
      }
95 95
 }
96
-function checkLoggerSettings(){
97
-	if(file_exists(getcwd().'/config.php')){
96
+function checkLoggerSettings() {
97
+	if (file_exists(getcwd().'/config.php')) {
98 98
          require(getcwd().'/config.php');
99 99
      }
100 100
     global $sugar_config;
101
-	if(!isset($sugar_config['logger'])){
102
-	    $sugar_config['logger'] =array (
101
+	if (!isset($sugar_config['logger'])) {
102
+	    $sugar_config['logger'] = array(
103 103
 			'level'=>'fatal',
104 104
 		    'file' =>
105
-		     array (
105
+		     array(
106 106
 		      'ext' => '.log',
107 107
 		      'name' => 'sugarcrm',
108 108
 		      'dateFormat' => '%c',
@@ -112,23 +112,23 @@  discard block
 block discarded – undo
112 112
 		    ),
113 113
 		  );
114 114
 		 ksort($sugar_config);
115
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
115
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
116 116
         	//writing to the file
117 117
  		}
118 118
 	 }
119 119
 }
120 120
 
121
-function checkResourceSettings(){
122
-	if(file_exists(getcwd().'/config.php')){
121
+function checkResourceSettings() {
122
+	if (file_exists(getcwd().'/config.php')) {
123 123
          require(getcwd().'/config.php');
124 124
      }
125 125
     global $sugar_config;
126
-	if(!isset($sugar_config['resource_management'])){
126
+	if (!isset($sugar_config['resource_management'])) {
127 127
 	  $sugar_config['resource_management'] =
128
-		  array (
128
+		  array(
129 129
 		    'special_query_limit' => 50000,
130 130
 		    'special_query_modules' =>
131
-		    array (
131
+		    array(
132 132
 		      0 => 'Reports',
133 133
 		      1 => 'Export',
134 134
 		      2 => 'Import',
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		    'default_limit' => 1000,
139 139
 		  );
140 140
 		 ksort($sugar_config);
141
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
141
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
142 142
         	//writing to the file
143 143
  		}
144 144
 	}
@@ -146,23 +146,23 @@  discard block
 block discarded – undo
146 146
 
147 147
 
148 148
 //rebuild all relationships...
149
-function rebuildRelations($pre_path = ''){
149
+function rebuildRelations($pre_path = '') {
150 150
 	$_REQUEST['silent'] = true;
151 151
 	include($pre_path.'modules/Administration/RebuildRelationship.php');
152 152
 	 $_REQUEST['upgradeWizard'] = true;
153 153
 	 include($pre_path.'modules/ACL/install_actions.php');
154 154
 }
155 155
 
156
-function createMissingRels(){
157
-	$relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
158
-	foreach($relForObjects as $relObjName=>$relModName){
156
+function createMissingRels() {
157
+	$relForObjects = array('leads'=>'Leads', 'campaigns'=>'Campaigns', 'prospects'=>'Prospects');
158
+	foreach ($relForObjects as $relObjName=>$relModName) {
159 159
 		//assigned_user
160 160
 		$guid = create_guid();
161 161
 		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
162
-		$result= $GLOBALS['db']->query($query, true);
162
+		$result = $GLOBALS['db']->query($query, true);
163 163
 		$a = null;
164 164
 		$a = $GLOBALS['db']->fetchByAssoc($result);
165
-		if(!isset($a['id']) && empty($a['id']) ){
165
+		if (!isset($a['id']) && empty($a['id'])) {
166 166
 			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
167 167
 						VALUES ('{$guid}', '{$relObjName}_assigned_user','Users','users','id','{$relModName}','{$relObjName}','assigned_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
168 168
 			$GLOBALS['db']->query($qRel);
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 		//modified_user
171 171
 		$guid = create_guid();
172 172
 		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
173
-		$result= $GLOBALS['db']->query($query, true);
173
+		$result = $GLOBALS['db']->query($query, true);
174 174
 		$a = null;
175 175
 		$a = $GLOBALS['db']->fetchByAssoc($result);
176
-		if(!isset($a['id']) && empty($a['id']) ){
176
+		if (!isset($a['id']) && empty($a['id'])) {
177 177
 			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
178 178
 						VALUES ('{$guid}', '{$relObjName}_modified_user','Users','users','id','{$relModName}','{$relObjName}','modified_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
179 179
 			$GLOBALS['db']->query($qRel);
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 		//created_by
182 182
 		$guid = create_guid();
183 183
 		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
184
-		$result= $GLOBALS['db']->query($query, true);
184
+		$result = $GLOBALS['db']->query($query, true);
185 185
 		$a = null;
186 186
 		$a = $GLOBALS['db']->fetchByAssoc($result);
187
-    	if(!isset($a['id']) && empty($a['id']) ){
187
+    	if (!isset($a['id']) && empty($a['id'])) {
188 188
 			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
189 189
 						VALUES ('{$guid}', '{$relObjName}_created_by','Users','users','id','{$relModName}','{$relObjName}','created_by',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
190 190
 			$GLOBALS['db']->query($qRel);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
  */
203 203
 function merge_passwordsetting($sugar_config, $sugar_version) {
204 204
     $passwordsetting_defaults = array(
205
-    'passwordsetting' => array (
205
+    'passwordsetting' => array(
206 206
         'SystemGeneratedPasswordON' => '',
207 207
         'generatepasswordtmpl' => '',
208 208
         'lostpasswordtmpl' => '',
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
         'systexpirationtime' => '',
215 215
         'systexpirationtype' => '0',
216 216
         'systexpirationlogin' => '',
217
-        ) ,
217
+        ),
218 218
     );
219 219
 
220 220
 
221
-    $sugar_config = sugarArrayMerge($passwordsetting_defaults, $sugar_config );
221
+    $sugar_config = sugarArrayMerge($passwordsetting_defaults, $sugar_config);
222 222
 
223 223
     // need to override version with default no matter what
224 224
     $sugar_config['sugar_version'] = $sugar_version;
225 225
 
226
-    ksort( $sugar_config );
226
+    ksort($sugar_config);
227 227
 
228
-    if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
228
+    if (write_array_to_file("sugar_config", $sugar_config, "config.php")) {
229 229
         return true;
230 230
     }
231 231
     else {
@@ -234,17 +234,17 @@  discard block
 block discarded – undo
234 234
 }
235 235
 
236 236
 function addDefaultModuleRoles($defaultRoles = array()) {
237
-	foreach($defaultRoles as $roleName=>$role){
238
-        foreach($role as $category=>$actions){
239
-            foreach($actions as $name=>$access_override){
237
+	foreach ($defaultRoles as $roleName=>$role) {
238
+        foreach ($role as $category=>$actions) {
239
+            foreach ($actions as $name=>$access_override) {
240 240
                     $query = "SELECT * FROM acl_actions WHERE name='$name' AND category = '$category' AND acltype='$roleName' AND deleted=0 ";
241 241
 					$result = $GLOBALS['db']->query($query);
242 242
 					//only add if an action with that name and category don't exist
243
-					$row=$GLOBALS['db']->fetchByAssoc($result);
243
+					$row = $GLOBALS['db']->fetchByAssoc($result);
244 244
 					if ($row == null) {
245 245
 	                	$guid = create_guid();
246 246
 	                	$currdate = gmdate($GLOBALS['timedate']->get_db_date_time_format());
247
-	                	$query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
247
+	                	$query = "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
248 248
 						$GLOBALS['db']->query($query);
249 249
 	                }
250 250
             }
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
 	}
253 253
 }
254 254
 
255
-function verifyArguments($argv,$usage_dce,$usage_regular){
255
+function verifyArguments($argv, $usage_dce, $usage_regular) {
256 256
     $upgradeType = '';
257 257
     $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
258
-    if(isset($argv[3])) {
259
-        if(is_dir($argv[3])) {
258
+    if (isset($argv[3])) {
259
+        if (is_dir($argv[3])) {
260 260
             $cwd = $argv[3];
261 261
             chdir($cwd);
262 262
         } else {
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
     }
268 268
 
269 269
     //check if this is an instance
270
-    if(is_file("{$cwd}/ini_setup.php")){
270
+    if (is_file("{$cwd}/ini_setup.php")) {
271 271
         // this is an instance
272 272
         $upgradeType = constant('DCE_INSTANCE');
273 273
         //now that this is dce instance we want to make sure that there are
274 274
         // 7 arguments
275
-        if(count($argv) < 7) {
275
+        if (count($argv) < 7) {
276 276
             echo "*******************************************************************************\n";
277 277
             echo "*** ERROR: Missing required parameters.  Received ".count($argv)." argument(s), require 7.\n";
278 278
             echo $usage_dce;
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             exit(1);
281 281
         }
282 282
         // this is an instance
283
-        if(!is_dir($argv[1])) { // valid directory . template path?
283
+        if (!is_dir($argv[1])) { // valid directory . template path?
284 284
             echo "*******************************************************************************\n";
285 285
             echo "*** ERROR: First argument must be a full path to the template. Got [ {$argv[1]} ].\n";
286 286
             echo $usage_dce;
@@ -288,18 +288,18 @@  discard block
 block discarded – undo
288 288
             exit(1);
289 289
         }
290 290
     }
291
-    else if(is_file("{$cwd}/include/entryPoint.php")) {
291
+    else if (is_file("{$cwd}/include/entryPoint.php")) {
292 292
         //this should be a regular sugar install
293 293
         $upgradeType = constant('SUGARCRM_INSTALL');
294 294
         //check if this is a valid zip file
295
-        if(!is_file($argv[1])) { // valid zip?
295
+        if (!is_file($argv[1])) { // valid zip?
296 296
             echo "*******************************************************************************\n";
297 297
             echo "*** ERROR: First argument must be a full path to the patch file. Got [ {$argv[1]} ].\n";
298 298
             echo $usage_regular;
299 299
             echo "FAILURE\n";
300 300
             exit(1);
301 301
         }
302
-        if(count($argv) < 5) {
302
+        if (count($argv) < 5) {
303 303
             echo "*******************************************************************************\n";
304 304
             echo "*** ERROR: Missing required parameters.  Received ".count($argv)." argument(s), require 5.\n";
305 305
             echo $usage_regular;
@@ -314,29 +314,29 @@  discard block
 block discarded – undo
314 314
         exit(1);
315 315
     }
316 316
 
317
-    if(isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')){
317
+    if (isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')) {
318 318
         require_once($argv[7].'SugarTemplateUtilties.php');
319 319
     }
320 320
 
321 321
     return $upgradeType;
322 322
 }
323 323
 
324
-function upgradeDCEFiles($argv,$instanceUpgradePath){
324
+function upgradeDCEFiles($argv, $instanceUpgradePath) {
325 325
 	//copy and update following files from upgrade package
326
-	$upgradeTheseFiles = array('cron.php','download.php','index.php','install.php','soap.php','sugar_version.php','vcal_server.php');
327
-	foreach($upgradeTheseFiles as $file){
326
+	$upgradeTheseFiles = array('cron.php', 'download.php', 'index.php', 'install.php', 'soap.php', 'sugar_version.php', 'vcal_server.php');
327
+	foreach ($upgradeTheseFiles as $file) {
328 328
 		$srcFile = clean_path("{$instanceUpgradePath}/$file");
329 329
 		$destFile = clean_path("{$argv[3]}/$file");
330
-		if(file_exists($srcFile)){
331
-			if(!is_dir(dirname($destFile))) {
330
+		if (file_exists($srcFile)) {
331
+			if (!is_dir(dirname($destFile))) {
332 332
 				mkdir_recursive(dirname($destFile)); // make sure the directory exists
333 333
 			}
334
-			copy_recursive($srcFile,$destFile);
334
+			copy_recursive($srcFile, $destFile);
335 335
 			$_GET['TEMPLATE_PATH'] = $destFile;
336 336
 			$_GET['CONVERT_FILE_ONLY'] = true;
337
-			if(!class_exists('TemplateConverter')){
337
+			if (!class_exists('TemplateConverter')) {
338 338
 				include($argv[7].'templateConverter.php');
339
-			}else{
339
+			} else {
340 340
 				TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
341 341
 			}
342 342
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
 
349 349
 
350
-function threeWayMerge(){
350
+function threeWayMerge() {
351 351
 	//using threeway merge apis
352 352
 }
353 353
 ////	END UTILITIES THAT MUST BE LOCAL :(
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 //End of #52872
362 362
 
363 363
 // only run from command line
364
-if(isset($_SERVER['HTTP_USER_AGENT'])) {
364
+if (isset($_SERVER['HTTP_USER_AGENT'])) {
365 365
 	fwrite(STDERR, 'This utility may only be run from the command line or command prompt.');
366 366
 	exit(1);
367 367
 }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
 ///////////////////////////////////////////////////////////////////////////////
373 373
 ////	USAGE
374
-$usage_dce =<<<eoq1
374
+$usage_dce = <<<eoq1
375 375
 Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance]
376 376
 
377 377
 On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 
393 393
 eoq1;
394 394
 
395
-$usage_regular =<<<eoq2
395
+$usage_regular = <<<eoq2
396 396
 Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance] [admin-user]
397 397
 
398 398
 On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 
415 415
 ///////////////////////////////////////////////////////////////////////////////
416 416
 ////	STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
417
-if(!defined('sugarEntry')) define('sugarEntry', true);
417
+if (!defined('sugarEntry')) define('sugarEntry', true);
418 418
 
419 419
 $_SESSION = array();
420 420
 $_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 global $cwd;
432 432
 $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
433 433
 
434
-$upgradeType = verifyArguments($argv,$usage_dce,$usage_regular);
434
+$upgradeType = verifyArguments($argv, $usage_dce, $usage_regular);
435 435
 
436 436
 ///////////////////////////////////////////////////////////////////////////////
437 437
 //////  Verify that all the arguments are appropriately placed////////////////
@@ -441,14 +441,14 @@  discard block
 block discarded – undo
441 441
 //$GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
442 442
 //require_once('/var/www/html/eddy/sugarnode/SugarTemplateUtilities.php');
443 443
 
444
-$path			= $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
444
+$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
445 445
 //$db				= &DBManagerFactory::getInstance();  //<---------
446 446
 
447 447
 
448 448
 //$UWstrings		= return_module_language('en_us', 'UpgradeWizard');
449 449
 //$adminStrings	= return_module_language('en_us', 'Administration');
450 450
 //$mod_strings	= array_merge($adminStrings, $UWstrings);
451
-$subdirs		= array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
451
+$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
452 452
 
453 453
 //$_REQUEST['zip_from_dir'] = $zip_from_dir;
454 454
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 $errors = array();
471 471
 
472 472
 
473
-if($upgradeType == constant('DCE_INSTANCE')){
473
+if ($upgradeType == constant('DCE_INSTANCE')) {
474 474
    	//$instanceUpgradePath = "{$argv[1]}/DCEUpgrade/{$zip_from_dir}";
475 475
    	//$instanceUpgradePath = "{$argv[1]}";
476 476
 	include ("ini_setup.php");
@@ -502,44 +502,44 @@  discard block
 block discarded – undo
502 502
 	/////retrieve admin user
503 503
 	$configOptions = $sugar_config['dbconfig'];
504 504
 
505
-	$GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
506
-	$db				= &DBManagerFactory::getInstance();
505
+	$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
506
+	$db = &DBManagerFactory::getInstance();
507 507
        		///////////////////////////////////////////////////////////////////////////////
508 508
 	////	MAKE SURE PATCH IS COMPATIBLE
509 509
 
510
-	if(is_file("{$argv[1]}/manifest.php")) {
510
+	if (is_file("{$argv[1]}/manifest.php")) {
511 511
 		// provides $manifest array
512 512
 		include("{$argv[1]}/manifest.php");
513 513
 	}
514 514
 	//If Instance then the files will be accessed from Template/DCEUpgrade folder
515 515
 	$zip_from_dir = '';
516
-    if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){
517
-	    $zip_from_dir   = $manifest['copy_files']['from_dir'];
516
+    if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
517
+	    $zip_from_dir = $manifest['copy_files']['from_dir'];
518 518
 	}
519 519
 	$instanceUpgradePath = "{$argv[1]}/{$zip_from_dir}";
520 520
 	global $instancePath;
521 521
 	$instancePath = $instanceUpgradePath;
522 522
 	$_SESSION['instancePath'] = $instancePath;
523
-	if(file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")){
523
+	if (file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")) {
524 524
 		require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
525 525
 	}
526
-	else{
526
+	else {
527 527
 		require_once("{$argv[4]}/modules/UpgradeWizard/uw_utils.php");
528 528
 	}
529
-    if(function_exists('set_upgrade_vars')){
529
+    if (function_exists('set_upgrade_vars')) {
530 530
 		set_upgrade_vars();
531 531
     }
532
-	if(is_file("$argv[1]/manifest.php")) {
532
+	if (is_file("$argv[1]/manifest.php")) {
533 533
 		// provides $manifest array
534 534
 		//include("$instanceUpgradePath/manifest.php");
535
-		if(!isset($manifest)) {
535
+		if (!isset($manifest)) {
536 536
 		    fwrite(STDERR, "\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
537 537
 		    exit(1);
538 538
 		} else {
539 539
 			$error = validate_manifest($manifest);
540
-			if(!empty($error)) {
540
+			if (!empty($error)) {
541 541
 				$error = strip_tags(br2nl($error));
542
-				fwrite(STDERR,"\n{$error}\n\nFAILURE\n");
542
+				fwrite(STDERR, "\n{$error}\n\nFAILURE\n");
543 543
 				exit(1);
544 544
 			}
545 545
 		}
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 	logThis("*** UpgradeWizard Upgraded  ", $path);
558 558
 	$_SESSION['sugar_version_file'] = '';
559 559
 	$srcFile = clean_path("{$instanceUpgradePath}/sugar_version.php");
560
-	if(file_exists($srcFile)) {
560
+	if (file_exists($srcFile)) {
561 561
 		logThis('Save the version file in session variable', $path);
562 562
 		$_SESSION['sugar_version_file'] = $srcFile;
563 563
 	}
@@ -566,25 +566,25 @@  discard block
 block discarded – undo
566 566
 
567 567
     //check exit on conflicts
568 568
     $exitOnConflict = 'yes'; //default
569
-    if($argv[5] != null && !empty($argv[5])){
570
-    	if(strtolower($argv[5]) == 'no'){
569
+    if ($argv[5] != null && !empty($argv[5])) {
570
+    	if (strtolower($argv[5]) == 'no') {
571 571
     	  $exitOnConflict = 'no'; //override
572 572
     	}
573 573
     }
574
-    if($exitOnConflict == 'yes'){
574
+    if ($exitOnConflict == 'yes') {
575 575
     	$customFiles = array();
576 576
     	$customFiles = findAllFiles(clean_path("{$argv[3]}/custom"), $customFiles);
577
-    	if($customFiles != null){
577
+    	if ($customFiles != null) {
578 578
     		logThis("*** ****************************  ****", $path);
579 579
 			logThis("*** START LOGGING CUSTOM FILES  ****", $path);
580 580
 			$existsCustomFile = false;
581
-			foreach($customFiles as $file) {
581
+			foreach ($customFiles as $file) {
582 582
 			$srcFile = clean_path($file);
583 583
 			//$targetFile = clean_path(getcwd() . '/' . $srcFile);
584
-			    if (strpos($srcFile,".svn") !== false) {
584
+			    if (strpos($srcFile, ".svn") !== false) {
585 585
 				  //do nothing
586 586
 			    }
587
-			    else{
587
+			    else {
588 588
 			     $existsCustomFile = true;
589 589
 			     //log the custom file in
590 590
 			     logThis($file, $path);
@@ -592,23 +592,23 @@  discard block
 block discarded – undo
592 592
 			}
593 593
 			logThis("*** END LOGGING CUSTOM FILES  ****", $path);
594 594
 			logThis("*** ****************************  ****", $path);
595
-			if($existsCustomFile){
595
+			if ($existsCustomFile) {
596 596
 				echo 'Stop and Exit Upgrade. There are customized files. Take a look in the upgrade log';
597 597
 				logThis("Stop and Exit Upgrade. There are customized files. Take a look in the upgrade log", $path);
598 598
 				exit(1);
599 599
 			}
600
-			else{
601
-			    upgradeDCEFiles($argv,$instanceUpgradePath);
600
+			else {
601
+			    upgradeDCEFiles($argv, $instanceUpgradePath);
602 602
 			}
603 603
     	}
604
-    	else{
604
+    	else {
605 605
 			   //copy and update following files from upgrade package
606
-				upgradeDCEFiles($argv,$instanceUpgradePath);
606
+				upgradeDCEFiles($argv, $instanceUpgradePath);
607 607
 		 }
608 608
     }
609
-    else{
609
+    else {
610 610
 	   //copy and update following files from upgrade package
611
-	   upgradeDCEFiles($argv,$instanceUpgradePath);
611
+	   upgradeDCEFiles($argv, $instanceUpgradePath);
612 612
     }
613 613
 
614 614
     global $unzip_dir;
@@ -625,8 +625,8 @@  discard block
 block discarded – undo
625 625
 ob_end_clean();
626 626
 logThis("**** Potential PHP generated error messages: {$phpErrors}", $path);
627 627
 
628
-if(count($errors) > 0) {
629
-	foreach($errors as $error) {
628
+if (count($errors) > 0) {
629
+	foreach ($errors as $error) {
630 630
 		logThis("****** SilentUpgrade ERROR: {$error}", $path);
631 631
 	}
632 632
 	echo "FAILED\n";
Please login to merge, or discard this patch.
Braces   +13 added lines, -20 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@  discard block
 block discarded – undo
65 65
 			if ($children != "." && $children != "..") {
66 66
 				if (is_dir($thedir . "/" . $children)) {
67 67
 					clearCacheSU($thedir . "/" . $children, $extension);
68
-				}
69
-				elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
68
+				} elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
70 69
 					unlink($thedir . "/" . $children);
71 70
 				}
72 71
 			}
@@ -227,8 +226,7 @@  discard block
 block discarded – undo
227 226
 
228 227
     if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
229 228
         return true;
230
-    }
231
-    else {
229
+    } else {
232 230
         return false;
233 231
     }
234 232
 }
@@ -287,8 +285,7 @@  discard block
 block discarded – undo
287 285
             echo "FAILURE\n";
288 286
             exit(1);
289 287
         }
290
-    }
291
-    else if(is_file("{$cwd}/include/entryPoint.php")) {
288
+    } else if(is_file("{$cwd}/include/entryPoint.php")) {
292 289
         //this should be a regular sugar install
293 290
         $upgradeType = constant('SUGARCRM_INSTALL');
294 291
         //check if this is a valid zip file
@@ -306,8 +303,7 @@  discard block
 block discarded – undo
306 303
             echo "FAILURE\n";
307 304
             exit(1);
308 305
         }
309
-    }
310
-    else {
306
+    } else {
311 307
         //this should be a regular sugar install
312 308
         echo "*******************************************************************************\n";
313 309
         echo "*** ERROR: Tried to execute in a non-SugarCRM root directory.\n";
@@ -336,7 +332,7 @@  discard block
 block discarded – undo
336 332
 			$_GET['CONVERT_FILE_ONLY'] = true;
337 333
 			if(!class_exists('TemplateConverter')){
338 334
 				include($argv[7].'templateConverter.php');
339
-			}else{
335
+			} else{
340 336
 				TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
341 337
 			}
342 338
 
@@ -414,7 +410,9 @@  discard block
 block discarded – undo
414 410
 
415 411
 ///////////////////////////////////////////////////////////////////////////////
416 412
 ////	STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
417
-if(!defined('sugarEntry')) define('sugarEntry', true);
413
+if(!defined('sugarEntry')) {
414
+    define('sugarEntry', true);
415
+}
418 416
 
419 417
 $_SESSION = array();
420 418
 $_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
@@ -522,8 +520,7 @@  discard block
 block discarded – undo
522 520
 	$_SESSION['instancePath'] = $instancePath;
523 521
 	if(file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")){
524 522
 		require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
525
-	}
526
-	else{
523
+	} else{
527 524
 		require_once("{$argv[4]}/modules/UpgradeWizard/uw_utils.php");
528 525
 	}
529 526
     if(function_exists('set_upgrade_vars')){
@@ -583,8 +580,7 @@  discard block
 block discarded – undo
583 580
 			//$targetFile = clean_path(getcwd() . '/' . $srcFile);
584 581
 			    if (strpos($srcFile,".svn") !== false) {
585 582
 				  //do nothing
586
-			    }
587
-			    else{
583
+			    } else{
588 584
 			     $existsCustomFile = true;
589 585
 			     //log the custom file in
590 586
 			     logThis($file, $path);
@@ -596,17 +592,14 @@  discard block
 block discarded – undo
596 592
 				echo 'Stop and Exit Upgrade. There are customized files. Take a look in the upgrade log';
597 593
 				logThis("Stop and Exit Upgrade. There are customized files. Take a look in the upgrade log", $path);
598 594
 				exit(1);
599
-			}
600
-			else{
595
+			} else{
601 596
 			    upgradeDCEFiles($argv,$instanceUpgradePath);
602 597
 			}
603
-    	}
604
-    	else{
598
+    	} else{
605 599
 			   //copy and update following files from upgrade package
606 600
 				upgradeDCEFiles($argv,$instanceUpgradePath);
607 601
 		 }
608
-    }
609
-    else{
602
+    } else{
610 603
 	   //copy and update following files from upgrade package
611 604
 	   upgradeDCEFiles($argv,$instanceUpgradePath);
612 605
     }
Please login to merge, or discard this patch.
modules/UpgradeWizard/silentUpgrade_step1.php 3 patches
Indentation   +575 added lines, -575 removed lines patch added patch discarded remove patch
@@ -46,81 +46,81 @@  discard block
 block discarded – undo
46 46
 ///////////////////////////////////////////////////////////////////////////////
47 47
 ////	UTILITIES THAT MUST BE LOCAL :(
48 48
 function prepSystemForUpgradeSilent() {
49
-	global $subdirs;
50
-	global $cwd;
51
-	global $sugar_config;
52
-
53
-	// make sure dirs exist
54
-	foreach($subdirs as $subdir) {
55
-		if(!is_dir($sugar_config['upload_dir']."/upgrades/{$subdir}")) {
56
-	    	mkdir_recursive($sugar_config['upload_dir']."/upgrades/{$subdir}");
57
-		}
58
-	}
49
+    global $subdirs;
50
+    global $cwd;
51
+    global $sugar_config;
52
+
53
+    // make sure dirs exist
54
+    foreach($subdirs as $subdir) {
55
+        if(!is_dir($sugar_config['upload_dir']."/upgrades/{$subdir}")) {
56
+            mkdir_recursive($sugar_config['upload_dir']."/upgrades/{$subdir}");
57
+        }
58
+    }
59 59
 }
60 60
 
61 61
 //local function for clearing cache
62 62
 function clearCacheSU($thedir, $extension) {
63
-	if ($current = @opendir($thedir)) {
64
-		while (false !== ($children = readdir($current))) {
65
-			if ($children != "." && $children != "..") {
66
-				if (is_dir($thedir . "/" . $children)) {
67
-					clearCacheSU($thedir . "/" . $children, $extension);
68
-				}
69
-				elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
70
-					unlink($thedir . "/" . $children);
71
-				}
72
-			}
73
-		}
74
-	}
75
- }
76
- //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
77
- //no found then adds default_permissions to the config file.
78
- function checkConfigForPermissions(){
79
-     if(file_exists(getcwd().'/config.php')){
80
-         require(getcwd().'/config.php');
81
-     }
82
-     global $sugar_config;
83
-     if(!isset($sugar_config['default_permissions'])){
84
-             $sugar_config['default_permissions'] = array (
85
-                     'dir_mode' => 02770,
86
-                     'file_mode' => 0660,
87
-                     'user' => '',
88
-                     'group' => '',
89
-             );
90
-         ksort($sugar_config);
91
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
92
-        	//writing to the file
93
- 		}
94
-     }
63
+    if ($current = @opendir($thedir)) {
64
+        while (false !== ($children = readdir($current))) {
65
+            if ($children != "." && $children != "..") {
66
+                if (is_dir($thedir . "/" . $children)) {
67
+                    clearCacheSU($thedir . "/" . $children, $extension);
68
+                }
69
+                elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
70
+                    unlink($thedir . "/" . $children);
71
+                }
72
+            }
73
+        }
74
+    }
75
+    }
76
+    //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
77
+    //no found then adds default_permissions to the config file.
78
+    function checkConfigForPermissions(){
79
+        if(file_exists(getcwd().'/config.php')){
80
+            require(getcwd().'/config.php');
81
+        }
82
+        global $sugar_config;
83
+        if(!isset($sugar_config['default_permissions'])){
84
+                $sugar_config['default_permissions'] = array (
85
+                        'dir_mode' => 02770,
86
+                        'file_mode' => 0660,
87
+                        'user' => '',
88
+                        'group' => '',
89
+                );
90
+            ksort($sugar_config);
91
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
92
+            //writing to the file
93
+            }
94
+        }
95 95
 }
96 96
 function checkLoggerSettings(){
97
-	if(file_exists(getcwd().'/config.php')){
98
-         require(getcwd().'/config.php');
99
-     }
97
+    if(file_exists(getcwd().'/config.php')){
98
+            require(getcwd().'/config.php');
99
+        }
100 100
     global $sugar_config;
101
-	if(!isset($sugar_config['logger'])){
102
-	    $sugar_config['logger'] =array (
103
-			'level'=>'fatal',
104
-		    'file' =>
105
-		     array (
106
-		      'ext' => '.log',
107
-		      'name' => 'sugarcrm',
108
-		      'dateFormat' => '%c',
109
-		      'maxSize' => '10MB',
110
-		      'maxLogs' => 10,
111
-		      'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
112
-		    ),
113
-		  );
114
-		 ksort($sugar_config);
115
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
116
-        	//writing to the file
117
- 		}
118
-	 }
101
+    if(!isset($sugar_config['logger'])){
102
+        $sugar_config['logger'] =array (
103
+            'level'=>'fatal',
104
+            'file' =>
105
+                array (
106
+                'ext' => '.log',
107
+                'name' => 'sugarcrm',
108
+                'dateFormat' => '%c',
109
+                'maxSize' => '10MB',
110
+                'maxLogs' => 10,
111
+                'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
112
+            ),
113
+            );
114
+            ksort($sugar_config);
115
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
116
+            //writing to the file
117
+            }
118
+        }
119 119
 }
120 120
 
121 121
 function checkLeadConversionSettings() {
122 122
     if (file_exists(getcwd().'/config.php')) {
123
-         require(getcwd().'/config.php');
123
+            require(getcwd().'/config.php');
124 124
     }
125 125
     global $sugar_config;
126 126
     if (!isset($sugar_config['lead_conv_activity_opt'])) {
@@ -133,90 +133,90 @@  discard block
 block discarded – undo
133 133
 }
134 134
 
135 135
 function checkResourceSettings(){
136
-	if(file_exists(getcwd().'/config.php')){
137
-         require(getcwd().'/config.php');
138
-     }
136
+    if(file_exists(getcwd().'/config.php')){
137
+            require(getcwd().'/config.php');
138
+        }
139 139
     global $sugar_config;
140
-	if(!isset($sugar_config['resource_management'])){
141
-	  $sugar_config['resource_management'] =
142
-		  array (
143
-		    'special_query_limit' => 50000,
144
-		    'special_query_modules' =>
145
-		    array (
146
-		      0 => 'Reports',
147
-		      1 => 'Export',
148
-		      2 => 'Import',
149
-		      3 => 'Administration',
150
-		      4 => 'Sync',
151
-		    ),
152
-		    'default_limit' => 1000,
153
-		  );
154
-		 ksort($sugar_config);
155
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
156
-        	//writing to the file
157
- 		}
158
-	}
140
+    if(!isset($sugar_config['resource_management'])){
141
+        $sugar_config['resource_management'] =
142
+            array (
143
+            'special_query_limit' => 50000,
144
+            'special_query_modules' =>
145
+            array (
146
+                0 => 'Reports',
147
+                1 => 'Export',
148
+                2 => 'Import',
149
+                3 => 'Administration',
150
+                4 => 'Sync',
151
+            ),
152
+            'default_limit' => 1000,
153
+            );
154
+            ksort($sugar_config);
155
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
156
+            //writing to the file
157
+            }
158
+    }
159 159
 }
160 160
 
161 161
 
162 162
 function createMissingRels(){
163
-	$relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
164
-	foreach($relForObjects as $relObjName=>$relModName){
165
-		//assigned_user
166
-		$guid = create_guid();
167
-		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
168
-		$result= $GLOBALS['db']->query($query, true);
169
-		$a = null;
170
-		$a = $GLOBALS['db']->fetchByAssoc($result);
171
-		if(!isset($a['id']) && empty($a['id']) ){
172
-			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
163
+    $relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
164
+    foreach($relForObjects as $relObjName=>$relModName){
165
+        //assigned_user
166
+        $guid = create_guid();
167
+        $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
168
+        $result= $GLOBALS['db']->query($query, true);
169
+        $a = null;
170
+        $a = $GLOBALS['db']->fetchByAssoc($result);
171
+        if(!isset($a['id']) && empty($a['id']) ){
172
+            $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
173 173
 						VALUES ('{$guid}', '{$relObjName}_assigned_user','Users','users','id','{$relModName}','{$relObjName}','assigned_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
174
-			$GLOBALS['db']->query($qRel);
175
-		}
176
-		//modified_user
177
-		$guid = create_guid();
178
-		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
179
-		$result= $GLOBALS['db']->query($query, true);
180
-		$a = null;
181
-		$a = $GLOBALS['db']->fetchByAssoc($result);
182
-		if(!isset($a['id']) && empty($a['id']) ){
183
-			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
174
+            $GLOBALS['db']->query($qRel);
175
+        }
176
+        //modified_user
177
+        $guid = create_guid();
178
+        $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
179
+        $result= $GLOBALS['db']->query($query, true);
180
+        $a = null;
181
+        $a = $GLOBALS['db']->fetchByAssoc($result);
182
+        if(!isset($a['id']) && empty($a['id']) ){
183
+            $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
184 184
 						VALUES ('{$guid}', '{$relObjName}_modified_user','Users','users','id','{$relModName}','{$relObjName}','modified_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
185
-			$GLOBALS['db']->query($qRel);
186
-		}
187
-		//created_by
188
-		$guid = create_guid();
189
-		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
190
-		$result= $GLOBALS['db']->query($query, true);
191
-		$a = null;
192
-		$a = $GLOBALS['db']->fetchByAssoc($result);
193
-    	if(!isset($a['id']) && empty($a['id']) ){
194
-			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
185
+            $GLOBALS['db']->query($qRel);
186
+        }
187
+        //created_by
188
+        $guid = create_guid();
189
+        $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
190
+        $result= $GLOBALS['db']->query($query, true);
191
+        $a = null;
192
+        $a = $GLOBALS['db']->fetchByAssoc($result);
193
+        if(!isset($a['id']) && empty($a['id']) ){
194
+            $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
195 195
 						VALUES ('{$guid}', '{$relObjName}_created_by','Users','users','id','{$relModName}','{$relObjName}','created_by',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
196
-			$GLOBALS['db']->query($qRel);
197
-    	}
198
-		$guid = create_guid();
199
-		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_team'";
200
-		$result= $GLOBALS['db']->query($query, true);
201
-		$a = null;
202
-		$a = $GLOBALS['db']->fetchByAssoc($result);
203
-		if(!isset($a['id']) && empty($a['id']) ){
204
-			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
196
+            $GLOBALS['db']->query($qRel);
197
+        }
198
+        $guid = create_guid();
199
+        $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_team'";
200
+        $result= $GLOBALS['db']->query($query, true);
201
+        $a = null;
202
+        $a = $GLOBALS['db']->fetchByAssoc($result);
203
+        if(!isset($a['id']) && empty($a['id']) ){
204
+            $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
205 205
 							VALUES ('{$guid}', '{$relObjName}_team','Teams','teams','id','{$relModName}','{$relObjName}','team_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
206
-			$GLOBALS['db']->query($qRel);
207
-		}
208
-	}
209
-	//Also add tracker perf relationship
210
-	$guid = create_guid();
211
-	$query = "SELECT id FROM relationships WHERE relationship_name = 'tracker_monitor_id'";
212
-	$result= $GLOBALS['db']->query($query, true);
213
-	$a = null;
214
-	$a = $GLOBALS['db']->fetchByAssoc($result);
215
-	if(!isset($a['id']) && empty($a['id']) ){
216
-		$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
206
+            $GLOBALS['db']->query($qRel);
207
+        }
208
+    }
209
+    //Also add tracker perf relationship
210
+    $guid = create_guid();
211
+    $query = "SELECT id FROM relationships WHERE relationship_name = 'tracker_monitor_id'";
212
+    $result= $GLOBALS['db']->query($query, true);
213
+    $a = null;
214
+    $a = $GLOBALS['db']->fetchByAssoc($result);
215
+    if(!isset($a['id']) && empty($a['id']) ){
216
+        $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
217 217
 					VALUES ('{$guid}', 'tracker_monitor_id','TrackerPerfs','tracker_perf','monitor_id','Trackers','tracker','monitor_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
218
-		$GLOBALS['db']->query($qRel);
219
-	}
218
+        $GLOBALS['db']->query($qRel);
219
+    }
220 220
 }
221 221
 
222 222
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
  */
229 229
 function merge_passwordsetting($sugar_config, $sugar_version) {
230 230
 
231
-     $passwordsetting_defaults = array (
231
+        $passwordsetting_defaults = array (
232 232
         'passwordsetting' => array (
233 233
             'minpwdlength' => '',
234 234
             'maxpwdlength' => '',
@@ -276,22 +276,22 @@  discard block
 block discarded – undo
276 276
 }
277 277
 
278 278
 function addDefaultModuleRoles($defaultRoles = array()) {
279
-	foreach($defaultRoles as $roleName=>$role){
279
+    foreach($defaultRoles as $roleName=>$role){
280 280
         foreach($role as $category=>$actions){
281 281
             foreach($actions as $name=>$access_override){
282 282
                     $query = "SELECT * FROM acl_actions WHERE name='$name' AND category = '$category' AND acltype='$roleName' AND deleted=0 ";
283
-					$result = $GLOBALS['db']->query($query);
284
-					//only add if an action with that name and category don't exist
285
-					$row=$GLOBALS['db']->fetchByAssoc($result);
286
-					if ($row == null) {
287
-	                	$guid = create_guid();
288
-	                	$currdate = gmdate('Y-m-d H:i:s');
289
-	                	$query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
290
-						$GLOBALS['db']->query($query);
291
-	                }
283
+                    $result = $GLOBALS['db']->query($query);
284
+                    //only add if an action with that name and category don't exist
285
+                    $row=$GLOBALS['db']->fetchByAssoc($result);
286
+                    if ($row == null) {
287
+                        $guid = create_guid();
288
+                        $currdate = gmdate('Y-m-d H:i:s');
289
+                        $query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
290
+                        $GLOBALS['db']->query($query);
291
+                    }
292 292
             }
293 293
         }
294
-	}
294
+    }
295 295
 }
296 296
 
297 297
 function verifyArguments($argv,$usage_regular){
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 
344 344
 
345 345
 function threeWayMerge(){
346
-	//using threeway merge apis
346
+    //using threeway merge apis
347 347
 }
348 348
 
349 349
 ////	END UTILITIES THAT MUST BE LOCAL :(
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 
359 359
 // only run from command line
360 360
 if(isset($_SERVER['HTTP_USER_AGENT'])) {
361
-	fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
362
-	exit(1);
361
+    fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
362
+    exit(1);
363 363
 }
364 364
 //Clean_string cleans out any file  passed in as a parameter
365 365
 $_SERVER['PHP_SELF'] = 'silentUpgrade.php';
@@ -433,10 +433,10 @@  discard block
 block discarded – undo
433 433
 
434 434
 if($upgradeType != constant('DCE_INSTANCE')) {
435 435
 
436
-	ini_set('error_reporting',1);
437
-	require_once('include/entryPoint.php');
438
-	require_once('include/SugarLogger/SugarLogger.php');
439
-	require_once('include/utils/zip_utils.php');
436
+    ini_set('error_reporting',1);
437
+    require_once('include/entryPoint.php');
438
+    require_once('include/SugarLogger/SugarLogger.php');
439
+    require_once('include/utils/zip_utils.php');
440 440
 
441 441
 
442 442
 if(!function_exists('sugar_cached'))
@@ -460,64 +460,64 @@  discard block
 block discarded – undo
460 460
     }
461 461
 }
462 462
 
463
-	require('config.php');
464
-	//require_once('modules/UpgradeWizard/uw_utils.php'); // must upgrade UW first
465
-	if(isset($argv[3])) {
466
-		if(is_dir($argv[3])) {
467
-			$cwd = $argv[3];
468
-			chdir($cwd);
469
-		}
470
-	}
463
+    require('config.php');
464
+    //require_once('modules/UpgradeWizard/uw_utils.php'); // must upgrade UW first
465
+    if(isset($argv[3])) {
466
+        if(is_dir($argv[3])) {
467
+            $cwd = $argv[3];
468
+            chdir($cwd);
469
+        }
470
+    }
471 471
 
472
-	require_once("{$cwd}/sugar_version.php"); // provides $sugar_version & $sugar_flavor
472
+    require_once("{$cwd}/sugar_version.php"); // provides $sugar_version & $sugar_flavor
473 473
 
474 474
     $GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
475
-	$patchName		= basename($argv[1]);
476
-	$zip_from_dir	= substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip")
477
-	$path			= $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
475
+    $patchName		= basename($argv[1]);
476
+    $zip_from_dir	= substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip")
477
+    $path			= $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
478 478
 
479 479
     $db				= &DBManagerFactory::getInstance();
480
-	$UWstrings		= return_module_language('en_us', 'UpgradeWizard');
481
-	$adminStrings	= return_module_language('en_us', 'Administration');
480
+    $UWstrings		= return_module_language('en_us', 'UpgradeWizard');
481
+    $adminStrings	= return_module_language('en_us', 'Administration');
482 482
     $app_list_strings = return_app_list_strings_language('en_us');
483
-	$mod_strings	= array_merge($adminStrings, $UWstrings);
484
-	$subdirs		= array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
485
-	global $unzip_dir;
483
+    $mod_strings	= array_merge($adminStrings, $UWstrings);
484
+    $subdirs		= array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
485
+    global $unzip_dir;
486 486
     $license_accepted = false;
487 487
     if(isset($argv[5]) && (strtolower($argv[5])=='yes' || strtolower($argv[5])=='y')){
488
-    	$license_accepted = true;
489
-	 }
490
-	//////////////////////////////////////////////////////////////////////////////
491
-	//Adding admin user to the silent upgrade
492
-
493
-	$current_user = new User();
494
-	if(isset($argv[4])) {
495
-	   //if being used for internal upgrades avoid admin user verification
496
-	   $user_name = $argv[4];
497
-	   $q = "select id from users where user_name = '" . $user_name . "' and is_admin=1";
498
-	   $result = $GLOBALS['db']->query($q, false);
499
-	   $logged_user = $GLOBALS['db']->fetchByAssoc($result);
500
-	   if(isset($logged_user['id']) && $logged_user['id'] != null){
501
-		//do nothing
502
-	    $current_user->retrieve($logged_user['id']);
503
-	   }
504
-	   else{
505
-	   	echo "FAILURE: Not an admin user in users table. Please provide an admin user\n";
506
-		exit(1);
507
-	   }
508
-	}
509
-	else {
510
-		echo "*******************************************************************************\n";
511
-		echo "*** ERROR: 4th parameter must be a valid admin user.\n";
512
-		echo $usage;
513
-		echo "FAILURE\n";
514
-		exit(1);
515
-	}
516
-
517
-
518
-		/////retrieve admin user
519
-	global $sugar_config;
520
-	$configOptions = $sugar_config['dbconfig'];
488
+        $license_accepted = true;
489
+        }
490
+    //////////////////////////////////////////////////////////////////////////////
491
+    //Adding admin user to the silent upgrade
492
+
493
+    $current_user = new User();
494
+    if(isset($argv[4])) {
495
+        //if being used for internal upgrades avoid admin user verification
496
+        $user_name = $argv[4];
497
+        $q = "select id from users where user_name = '" . $user_name . "' and is_admin=1";
498
+        $result = $GLOBALS['db']->query($q, false);
499
+        $logged_user = $GLOBALS['db']->fetchByAssoc($result);
500
+        if(isset($logged_user['id']) && $logged_user['id'] != null){
501
+        //do nothing
502
+        $current_user->retrieve($logged_user['id']);
503
+        }
504
+        else{
505
+            echo "FAILURE: Not an admin user in users table. Please provide an admin user\n";
506
+        exit(1);
507
+        }
508
+    }
509
+    else {
510
+        echo "*******************************************************************************\n";
511
+        echo "*** ERROR: 4th parameter must be a valid admin user.\n";
512
+        echo $usage;
513
+        echo "FAILURE\n";
514
+        exit(1);
515
+    }
516
+
517
+
518
+        /////retrieve admin user
519
+    global $sugar_config;
520
+    $configOptions = $sugar_config['dbconfig'];
521 521
 
522 522
 
523 523
 ///////////////////////////////////////////////////////////////////////////////
@@ -535,17 +535,17 @@  discard block
 block discarded – undo
535 535
 $_SESSION['zip_from_dir'] = $zip_from_dir;
536 536
 if(is_dir($unzip_dir.'/scripts'))
537 537
 {
538
-	rmdir_recursive($unzip_dir.'/scripts');
538
+    rmdir_recursive($unzip_dir.'/scripts');
539 539
 }
540 540
 if(is_file($unzip_dir.'/manifest.php'))
541 541
 {
542
-	rmdir_recursive($unzip_dir.'/manifest.php');
542
+    rmdir_recursive($unzip_dir.'/manifest.php');
543 543
 }
544 544
 mkdir_recursive($unzip_dir);
545 545
 if(!is_dir($unzip_dir)) {
546
-	echo "\n{$unzip_dir} is not an available directory\nFAILURE\n";
547
-	fwrite(STDERR,"\n{$unzip_dir} is not an available directory\nFAILURE\n");
548
-	exit(1);
546
+    echo "\n{$unzip_dir} is not an available directory\nFAILURE\n";
547
+    fwrite(STDERR,"\n{$unzip_dir} is not an available directory\nFAILURE\n");
548
+    exit(1);
549 549
 }
550 550
 
551 551
 unzip($argv[1], $unzip_dir);
@@ -562,8 +562,8 @@  discard block
 block discarded – undo
562 562
 $destFiles = array();
563 563
 
564 564
 foreach($uwFiles as $uwFile) {
565
-	$destFile = str_replace($zipBasePath."/", '', $uwFile);
566
-	copy($uwFile, $destFile);
565
+    $destFile = str_replace($zipBasePath."/", '', $uwFile);
566
+    copy($uwFile, $destFile);
567 567
 }
568 568
 require_once('modules/UpgradeWizard/uw_utils.php'); // must upgrade UW first
569 569
 removeSilentUpgradeVarsCache(); // Clear the silent upgrade vars - Note: Any calls to these functions within this file are removed here
@@ -571,16 +571,16 @@  discard block
 block discarded – undo
571 571
 logThis("*** UpgradeWizard Upgraded  ", $path);
572 572
 
573 573
 if(function_exists('set_upgrade_vars')){
574
-	set_upgrade_vars();
574
+    set_upgrade_vars();
575 575
 }
576 576
 
577 577
 if($configOptions['db_type'] == 'mysql'){
578
-	//Change the db wait_timeout for this session
579
-	$now_timeout = $db->getOne("select @@wait_timeout");
580
-	logThis('Wait Timeout before change ***** '.$now_timeout , $path);
581
-	$db->query("set wait_timeout=28800");	
582
-	$now_timeout = $db->getOne("select @@wait_timeout");	
583
-	logThis('Wait Timeout after change ***** '.$now_timeout , $path);
578
+    //Change the db wait_timeout for this session
579
+    $now_timeout = $db->getOne("select @@wait_timeout");
580
+    logThis('Wait Timeout before change ***** '.$now_timeout , $path);
581
+    $db->query("set wait_timeout=28800");	
582
+    $now_timeout = $db->getOne("select @@wait_timeout");	
583
+    logThis('Wait Timeout after change ***** '.$now_timeout , $path);
584 584
 }
585 585
 
586 586
 ////	END UPGRADE UPGRADEWIZARD
@@ -589,24 +589,24 @@  discard block
 block discarded – undo
589 589
 ///////////////////////////////////////////////////////////////////////////////
590 590
 ////	MAKE SURE PATCH IS COMPATIBLE
591 591
 if(is_file("$unzip_dir/manifest.php")) {
592
-	// provides $manifest array
593
-	include("$unzip_dir/manifest.php");
594
-	if(!isset($manifest)) {
595
-		fwrite(STDERR,"\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
596
-	    exit(1);
597
-	} else {
598
-		copy("$unzip_dir/manifest.php", $sugar_config['upload_dir']."/upgrades/patch/{$zip_from_dir}-manifest.php");
599
-
600
-		$error = validate_manifest($manifest);
601
-		if(!empty($error)) {
602
-			$error = strip_tags(br2nl($error));
603
-			fwrite(STDERR,"\n{$error}\n\nFAILURE\n");
604
-			exit(1);
605
-		}
606
-	}
592
+    // provides $manifest array
593
+    include("$unzip_dir/manifest.php");
594
+    if(!isset($manifest)) {
595
+        fwrite(STDERR,"\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
596
+        exit(1);
597
+    } else {
598
+        copy("$unzip_dir/manifest.php", $sugar_config['upload_dir']."/upgrades/patch/{$zip_from_dir}-manifest.php");
599
+
600
+        $error = validate_manifest($manifest);
601
+        if(!empty($error)) {
602
+            $error = strip_tags(br2nl($error));
603
+            fwrite(STDERR,"\n{$error}\n\nFAILURE\n");
604
+            exit(1);
605
+        }
606
+    }
607 607
 } else {
608
-	fwrite(STDERR,"\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
609
-	exit(1);
608
+    fwrite(STDERR,"\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
609
+    exit(1);
610 610
 }
611 611
 
612 612
 $ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt' || $manifest['name'] == 'SugarCE to SugarCorp' || $manifest['name'] == 'SugarCE to SugarUlt');
@@ -624,17 +624,17 @@  discard block
 block discarded – undo
624 624
 ob_start();
625 625
 set_time_limit(0);
626 626
 if(file_exists('ModuleInstall/PackageManager/PackageManagerDisplay.php')) {
627
-	require_once('ModuleInstall/PackageManager/PackageManagerDisplay.php');
627
+    require_once('ModuleInstall/PackageManager/PackageManagerDisplay.php');
628 628
 }
629 629
 
630 630
 
631
-	//copy minimum required files including sugar_file_utils.php
632
-	if(file_exists("{$zipBasePath}/include/utils/sugar_file_utils.php")){
633
-		$destFile = clean_path(str_replace($zipBasePath, $cwd, "{$zipBasePath}/include/utils/sugar_file_utils.php"));
634
-		copy("{$zipBasePath}/include/utils/sugar_file_utils.php", $destFile);
635
-	}
636
-	if(file_exists('include/utils/sugar_file_utils.php')){
637
-    	require_once('include/utils/sugar_file_utils.php');
631
+    //copy minimum required files including sugar_file_utils.php
632
+    if(file_exists("{$zipBasePath}/include/utils/sugar_file_utils.php")){
633
+        $destFile = clean_path(str_replace($zipBasePath, $cwd, "{$zipBasePath}/include/utils/sugar_file_utils.php"));
634
+        copy("{$zipBasePath}/include/utils/sugar_file_utils.php", $destFile);
635
+    }
636
+    if(file_exists('include/utils/sugar_file_utils.php')){
637
+        require_once('include/utils/sugar_file_utils.php');
638 638
     }
639 639
 
640 640
 /*
@@ -649,101 +649,101 @@  discard block
 block discarded – undo
649 649
 */
650 650
 //If version less than 500 then look for modules to be upgraded
651 651
 if(function_exists('set_upgrade_vars')){
652
-	set_upgrade_vars();
652
+    set_upgrade_vars();
653 653
 }
654 654
 //Initialize the session variables. If upgrade_progress.php is already created
655 655
 //look for session vars there and restore them
656 656
 if(function_exists('initialize_session_vars')){
657
-	initialize_session_vars();
657
+    initialize_session_vars();
658 658
 }
659 659
 
660 660
 if(!didThisStepRunBefore('preflight')){
661
-	set_upgrade_progress('preflight','in_progress');
662
-	//Quickcreatedefs on the basis of editviewdefs
661
+    set_upgrade_progress('preflight','in_progress');
662
+    //Quickcreatedefs on the basis of editviewdefs
663 663
     updateQuickCreateDefs();
664
-	set_upgrade_progress('preflight','done');
664
+    set_upgrade_progress('preflight','done');
665 665
 }
666 666
 ////////////////COMMIT PROCESS BEGINS///////////////////////////////////////////////////////////////
667 667
 ////	MAKE BACKUPS OF TARGET FILES
668 668
 
669 669
 if(!didThisStepRunBefore('commit')){
670
-	set_upgrade_progress('commit','in_progress','commit','in_progress');
671
-	if(!didThisStepRunBefore('commit','commitMakeBackupFiles')){
672
-		set_upgrade_progress('commit','in_progress','commitMakeBackupFiles','in_progress');
673
-		$errors = commitMakeBackupFiles($rest_dir, $install_file, $unzip_dir, $zip_from_dir, array());
674
-		set_upgrade_progress('commit','in_progress','commitMakeBackupFiles','done');
675
-	}
676
-
677
-	//Need to make sure we have the matching copy of SetValueAction for static/instance method matching
670
+    set_upgrade_progress('commit','in_progress','commit','in_progress');
671
+    if(!didThisStepRunBefore('commit','commitMakeBackupFiles')){
672
+        set_upgrade_progress('commit','in_progress','commitMakeBackupFiles','in_progress');
673
+        $errors = commitMakeBackupFiles($rest_dir, $install_file, $unzip_dir, $zip_from_dir, array());
674
+        set_upgrade_progress('commit','in_progress','commitMakeBackupFiles','done');
675
+    }
676
+
677
+    //Need to make sure we have the matching copy of SetValueAction for static/instance method matching
678 678
     if(file_exists("include/Expressions/Actions/SetValueAction.php")){
679 679
         require_once("include/Expressions/Actions/SetValueAction.php");
680 680
     }
681 681
 
682
-	///////////////////////////////////////////////////////////////////////////////
683
-	////	HANDLE PREINSTALL SCRIPTS
684
-	if(empty($errors)) {
685
-		$file = "{$unzip_dir}/".constant('SUGARCRM_PRE_INSTALL_FILE');
686
-
687
-		if(is_file($file)) {
688
-			include($file);
689
-			if(!didThisStepRunBefore('commit','pre_install')){
690
-				set_upgrade_progress('commit','in_progress','pre_install','in_progress');
691
-				pre_install();
692
-				set_upgrade_progress('commit','in_progress','pre_install','done');
693
-			}
694
-		}
695
-	}
696
-
697
-	//Clean smarty from cache
698
-	$cachedir = sugar_cached('smarty');
699
-	if(is_dir($cachedir)){
700
-		$allModFiles = array();
701
-		$allModFiles = findAllFiles($cachedir,$allModFiles);
702
-	   foreach($allModFiles as $file){
703
-	       	//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
704
-	       	if(file_exists($file)){
705
-				unlink($file);
706
-	       	}
707
-	   }
708
-	}
709
-
710
-		//Also add the three-way merge here. The idea is after the 451 html files have
711
-		//been converted run the 3-way merge. If 500 then just run the 3-way merge
712
-		if(file_exists('modules/UpgradeWizard/SugarMerge/SugarMerge.php')){
713
-		    set_upgrade_progress('end','in_progress','threewaymerge','in_progress');
714
-		    require_once('modules/UpgradeWizard/SugarMerge/SugarMerge.php');
715
-		    $merger = new SugarMerge($zipBasePath);
716
-		    $merger->mergeAll();
717
-		    set_upgrade_progress('end','in_progress','threewaymerge','done');
718
-		}
719
-	///////////////////////////////////////////////////////////////////////////////
720
-	////	COPY NEW FILES INTO TARGET INSTANCE
721
-
722
-     if(!didThisStepRunBefore('commit','commitCopyNewFiles')){
723
-			set_upgrade_progress('commit','in_progress','commitCopyNewFiles','in_progress');
724
-			$split = commitCopyNewFiles($unzip_dir, $zip_from_dir);
725
-	 		$copiedFiles = $split['copiedFiles'];
726
-	 		$skippedFiles = $split['skippedFiles'];
727
-			set_upgrade_progress('commit','in_progress','commitCopyNewFiles','done');
728
-	 }
729
-	require_once(clean_path($unzip_dir.'/scripts/upgrade_utils.php'));
730
-	$new_sugar_version = getUpgradeVersion();
682
+    ///////////////////////////////////////////////////////////////////////////////
683
+    ////	HANDLE PREINSTALL SCRIPTS
684
+    if(empty($errors)) {
685
+        $file = "{$unzip_dir}/".constant('SUGARCRM_PRE_INSTALL_FILE');
686
+
687
+        if(is_file($file)) {
688
+            include($file);
689
+            if(!didThisStepRunBefore('commit','pre_install')){
690
+                set_upgrade_progress('commit','in_progress','pre_install','in_progress');
691
+                pre_install();
692
+                set_upgrade_progress('commit','in_progress','pre_install','done');
693
+            }
694
+        }
695
+    }
696
+
697
+    //Clean smarty from cache
698
+    $cachedir = sugar_cached('smarty');
699
+    if(is_dir($cachedir)){
700
+        $allModFiles = array();
701
+        $allModFiles = findAllFiles($cachedir,$allModFiles);
702
+        foreach($allModFiles as $file){
703
+                //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
704
+                if(file_exists($file)){
705
+                unlink($file);
706
+                }
707
+        }
708
+    }
709
+
710
+        //Also add the three-way merge here. The idea is after the 451 html files have
711
+        //been converted run the 3-way merge. If 500 then just run the 3-way merge
712
+        if(file_exists('modules/UpgradeWizard/SugarMerge/SugarMerge.php')){
713
+            set_upgrade_progress('end','in_progress','threewaymerge','in_progress');
714
+            require_once('modules/UpgradeWizard/SugarMerge/SugarMerge.php');
715
+            $merger = new SugarMerge($zipBasePath);
716
+            $merger->mergeAll();
717
+            set_upgrade_progress('end','in_progress','threewaymerge','done');
718
+        }
719
+    ///////////////////////////////////////////////////////////////////////////////
720
+    ////	COPY NEW FILES INTO TARGET INSTANCE
721
+
722
+        if(!didThisStepRunBefore('commit','commitCopyNewFiles')){
723
+            set_upgrade_progress('commit','in_progress','commitCopyNewFiles','in_progress');
724
+            $split = commitCopyNewFiles($unzip_dir, $zip_from_dir);
725
+                $copiedFiles = $split['copiedFiles'];
726
+                $skippedFiles = $split['skippedFiles'];
727
+            set_upgrade_progress('commit','in_progress','commitCopyNewFiles','done');
728
+        }
729
+    require_once(clean_path($unzip_dir.'/scripts/upgrade_utils.php'));
730
+    $new_sugar_version = getUpgradeVersion();
731 731
     $siv_varset_1 = setSilentUpgradeVar('origVersion', $sugar_version);
732 732
     $siv_varset_2 = setSilentUpgradeVar('destVersion', $new_sugar_version);
733 733
     $siv_write    = writeSilentUpgradeVars();
734 734
     if(!$siv_varset_1 || !$siv_varset_2 || !$siv_write){
735 735
         logThis("Error with silent upgrade variables: origVersion write success is ({$siv_varset_1}) ".
736
-        		"-- destVersion write success is ({$siv_varset_2}) -- ".
737
-        		"writeSilentUpgradeVars success is ({$siv_write}) -- ".
738
-        		"path to cache dir is ({$GLOBALS['sugar_config']['cache_dir']})", $path);
736
+                "-- destVersion write success is ({$siv_varset_2}) -- ".
737
+                "writeSilentUpgradeVars success is ({$siv_write}) -- ".
738
+                "path to cache dir is ({$GLOBALS['sugar_config']['cache_dir']})", $path);
739 739
     }
740
-     require_once('modules/DynamicFields/templates/Fields/TemplateText.php');
741
-	///////////////////////////////////////////////////////////////////////////////
740
+        require_once('modules/DynamicFields/templates/Fields/TemplateText.php');
741
+    ///////////////////////////////////////////////////////////////////////////////
742 742
     ///    RELOAD NEW DEFINITIONS
743 743
     global $ACLActions, $beanList, $beanFiles;
744 744
     include('modules/ACLActions/actiondefs.php');
745 745
     include('include/modules.php');
746
-	/////////////////////////////////////////////
746
+    /////////////////////////////////////////////
747 747
 
748 748
     if (!function_exists("inDeveloperMode")) {
749 749
         //this function was introduced from tokyo in the file include/utils.php, so when upgrading from 5.1x and 5.2x we should declare the this function
@@ -752,92 +752,92 @@  discard block
 block discarded – undo
752 752
             return isset($GLOBALS['sugar_config']['developerMode']) && $GLOBALS['sugar_config']['developerMode'];
753 753
         }
754 754
     }
755
-	///////////////////////////////////////////////////////////////////////////////
756
-	////	HANDLE POSTINSTALL SCRIPTS
757
-	if(empty($errors)) {
758
-		logThis('Starting post_install()...', $path);
755
+    ///////////////////////////////////////////////////////////////////////////////
756
+    ////	HANDLE POSTINSTALL SCRIPTS
757
+    if(empty($errors)) {
758
+        logThis('Starting post_install()...', $path);
759 759
 
760
-		$trackerManager = TrackerManager::getInstance();
760
+        $trackerManager = TrackerManager::getInstance();
761 761
         $trackerManager->pause();
762 762
         $trackerManager->unsetMonitors();
763 763
 
764
-		if(!didThisStepRunBefore('commit','post_install')){
765
-			$file = "$unzip_dir/" . constant('SUGARCRM_POST_INSTALL_FILE');
766
-			if(is_file($file)) {
767
-				//set_upgrade_progress('commit','in_progress','post_install','in_progress');
768
-				$progArray['post_install']='in_progress';
769
-				post_install_progress($progArray,'set');
770
-				    global $moduleList;
771
-					include($file);
772
-					post_install();
773
-				// cn: only run conversion if admin selects "Sugar runs SQL"
774
-				if(!empty($_SESSION['allTables']) && $_SESSION['schema_change'] == 'sugar')
775
-					executeConvertTablesSql($_SESSION['allTables']);
776
-				//set process to done
777
-				$progArray['post_install']='done';
778
-				//set_upgrade_progress('commit','in_progress','post_install','done');
779
-				post_install_progress($progArray,'set');
780
-			}
781
-		}
782
-	    //clean vardefs
783
-		logThis('Performing UWrebuild()...', $path);
784
-		ob_start();
785
-			@UWrebuild();
786
-		ob_end_clean();
787
-		logThis('UWrebuild() done.', $path);
788
-
789
-		logThis('begin check default permissions .', $path);
790
-	    	checkConfigForPermissions();
791
-	    logThis('end check default permissions .', $path);
792
-
793
-	    logThis('begin check logger settings .', $path);
794
-	    	checkLoggerSettings();
795
-	    logThis('begin check logger settings .', $path);
764
+        if(!didThisStepRunBefore('commit','post_install')){
765
+            $file = "$unzip_dir/" . constant('SUGARCRM_POST_INSTALL_FILE');
766
+            if(is_file($file)) {
767
+                //set_upgrade_progress('commit','in_progress','post_install','in_progress');
768
+                $progArray['post_install']='in_progress';
769
+                post_install_progress($progArray,'set');
770
+                    global $moduleList;
771
+                    include($file);
772
+                    post_install();
773
+                // cn: only run conversion if admin selects "Sugar runs SQL"
774
+                if(!empty($_SESSION['allTables']) && $_SESSION['schema_change'] == 'sugar')
775
+                    executeConvertTablesSql($_SESSION['allTables']);
776
+                //set process to done
777
+                $progArray['post_install']='done';
778
+                //set_upgrade_progress('commit','in_progress','post_install','done');
779
+                post_install_progress($progArray,'set');
780
+            }
781
+        }
782
+        //clean vardefs
783
+        logThis('Performing UWrebuild()...', $path);
784
+        ob_start();
785
+            @UWrebuild();
786
+        ob_end_clean();
787
+        logThis('UWrebuild() done.', $path);
788
+
789
+        logThis('begin check default permissions .', $path);
790
+            checkConfigForPermissions();
791
+        logThis('end check default permissions .', $path);
792
+
793
+        logThis('begin check logger settings .', $path);
794
+            checkLoggerSettings();
795
+        logThis('begin check logger settings .', $path);
796 796
 
797 797
             logThis('begin check lead conversion settings .', $path);
798 798
             checkLeadConversionSettings();
799
-	    logThis('end check lead conversion settings .', $path);
800
-
801
-	    logThis('begin check resource settings .', $path);
802
-			checkResourceSettings();
803
-		logThis('begin check resource settings .', $path);
804
-
805
-
806
-		require("sugar_version.php");
807
-		require('config.php');
808
-		global $sugar_config;
809
-
810
-		if($ce_to_pro_ent){
811
-			if(isset($sugar_config['sugarbeet']))
812
-			{
813
-			    //$sugar_config['sugarbeet'] is only set in COMM
814
-			    unset($sugar_config['sugarbeet']);
815
-			}
816
-		    if(isset($sugar_config['disable_team_access_check']))
817
-			{
818
-			    //$sugar_config['disable_team_access_check'] is a runtime configration,
819
-			    //no need to write to config.php
820
-			    unset($sugar_config['disable_team_access_check']);
821
-			}
822
-			if(!merge_passwordsetting($sugar_config, $sugar_version)) {
823
-				logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
824
-				$errors[] = 'Could not write config.php!';
825
-			}
826
-
827
-		}
828
-
829
-		logThis('Set default_theme to Sugar', $path);
830
-		$sugar_config['default_theme'] = 'Sugar';
831
-
832
-		if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) {
799
+        logThis('end check lead conversion settings .', $path);
800
+
801
+        logThis('begin check resource settings .', $path);
802
+            checkResourceSettings();
803
+        logThis('begin check resource settings .', $path);
804
+
805
+
806
+        require("sugar_version.php");
807
+        require('config.php');
808
+        global $sugar_config;
809
+
810
+        if($ce_to_pro_ent){
811
+            if(isset($sugar_config['sugarbeet']))
812
+            {
813
+                //$sugar_config['sugarbeet'] is only set in COMM
814
+                unset($sugar_config['sugarbeet']);
815
+            }
816
+            if(isset($sugar_config['disable_team_access_check']))
817
+            {
818
+                //$sugar_config['disable_team_access_check'] is a runtime configration,
819
+                //no need to write to config.php
820
+                unset($sugar_config['disable_team_access_check']);
821
+            }
822
+            if(!merge_passwordsetting($sugar_config, $sugar_version)) {
823
+                logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
824
+                $errors[] = 'Could not write config.php!';
825
+            }
826
+
827
+        }
828
+
829
+        logThis('Set default_theme to Sugar', $path);
830
+        $sugar_config['default_theme'] = 'Sugar';
831
+
832
+        if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) {
833 833
             logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
834 834
             $errors[] = 'Could not write config.php!';
835 835
         }
836 836
 
837 837
         logThis('Set default_max_tabs to 7', $path);
838
-		$sugar_config['default_max_tabs'] = '7';
838
+        $sugar_config['default_max_tabs'] = '7';
839 839
 
840
-		if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) {
840
+        if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) {
841 841
             logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
842 842
             $errors[] = 'Could not write config.php!';
843 843
         }
@@ -855,90 +855,90 @@  discard block
 block discarded – undo
855 855
             $errors[] = 'Could not write config.php!';
856 856
         }
857 857
 
858
-		logThis('post_install() done.', $path);
859
-	}
860
-
861
-	///////////////////////////////////////////////////////////////////////////////
862
-	////	REGISTER UPGRADE
863
-	if(empty($errors)) {
864
-		logThis('Registering upgrade with UpgradeHistory', $path);
865
-		if(!didThisStepRunBefore('commit','upgradeHistory')){
866
-			set_upgrade_progress('commit','in_progress','upgradeHistory','in_progress');
867
-			$file_action = "copied";
868
-			// if error was encountered, script should have died before now
869
-			$new_upgrade = new UpgradeHistory();
870
-			$new_upgrade->filename = $install_file;
871
-			$new_upgrade->md5sum = md5_file($install_file);
872
-			$new_upgrade->name = $zip_from_dir;
873
-			$new_upgrade->description = $manifest['description'];
874
-			$new_upgrade->type = 'patch';
875
-			$new_upgrade->version = $sugar_version;
876
-			$new_upgrade->status = "installed";
877
-			$new_upgrade->manifest = (!empty($_SESSION['install_manifest']) ? $_SESSION['install_manifest'] : '');
878
-
879
-			if($new_upgrade->description == null){
880
-				$new_upgrade->description = "Silent Upgrade was used to upgrade the instance";
881
-			}
882
-			else{
883
-				$new_upgrade->description = $new_upgrade->description." Silent Upgrade was used to upgrade the instance.";
884
-			}
885
-		   $new_upgrade->save();
886
-		   set_upgrade_progress('commit','in_progress','upgradeHistory','done');
887
-		   set_upgrade_progress('commit','done','commit','done');
888
-		}
889
-	  }
890
-
891
-	//Clean modules from cache
892
-	    $cachedir = sugar_cached('smarty');
893
-		if(is_dir($cachedir)){
894
-			$allModFiles = array();
895
-			$allModFiles = findAllFiles($cachedir,$allModFiles);
896
-		   foreach($allModFiles as $file){
897
-		       	//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
898
-		       	if(file_exists($file)){
899
-					unlink($file);
900
-		       	}
901
-		   }
902
-		}
903
-   //delete cache/modules before rebuilding the relations
904
-   	//Clean modules from cache
905
-   	    $cachedir = sugar_cached('modules');
906
-		if(is_dir($cachedir)){
907
-			$allModFiles = array();
908
-			$allModFiles = findAllFiles($cachedir,$allModFiles);
909
-		   foreach($allModFiles as $file){
910
-		       	//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
911
-		       	if(file_exists($file)){
912
-					unlink($file);
913
-		       	}
914
-		   }
915
-		}
916
-
917
-		//delete cache/themes
918
-		$cachedir = sugar_cached('themes');
919
-		if(is_dir($cachedir)){
920
-			$allModFiles = array();
921
-			$allModFiles = findAllFiles($cachedir,$allModFiles);
922
-		   foreach($allModFiles as $file){
923
-		       	//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
924
-		       	if(file_exists($file)){
925
-					unlink($file);
926
-		       	}
927
-		   }
928
-		}
929
-	ob_start();
930
-	if(!isset($_REQUEST['silent'])){
931
-		$_REQUEST['silent'] = true;
932
-	}
933
-	else if(isset($_REQUEST['silent']) && $_REQUEST['silent'] != true){
934
-		$_REQUEST['silent'] = true;
935
-	}
936
-
937
-	 //logThis('Checking for leads_assigned_user relationship and if not found then create.', $path);
938
-	@createMissingRels();
939
-	 //logThis('Checked for leads_assigned_user relationship.', $path);
940
-	ob_end_clean();
941
-	//// run fix on dropdown lists that may have been incorrectly named
858
+        logThis('post_install() done.', $path);
859
+    }
860
+
861
+    ///////////////////////////////////////////////////////////////////////////////
862
+    ////	REGISTER UPGRADE
863
+    if(empty($errors)) {
864
+        logThis('Registering upgrade with UpgradeHistory', $path);
865
+        if(!didThisStepRunBefore('commit','upgradeHistory')){
866
+            set_upgrade_progress('commit','in_progress','upgradeHistory','in_progress');
867
+            $file_action = "copied";
868
+            // if error was encountered, script should have died before now
869
+            $new_upgrade = new UpgradeHistory();
870
+            $new_upgrade->filename = $install_file;
871
+            $new_upgrade->md5sum = md5_file($install_file);
872
+            $new_upgrade->name = $zip_from_dir;
873
+            $new_upgrade->description = $manifest['description'];
874
+            $new_upgrade->type = 'patch';
875
+            $new_upgrade->version = $sugar_version;
876
+            $new_upgrade->status = "installed";
877
+            $new_upgrade->manifest = (!empty($_SESSION['install_manifest']) ? $_SESSION['install_manifest'] : '');
878
+
879
+            if($new_upgrade->description == null){
880
+                $new_upgrade->description = "Silent Upgrade was used to upgrade the instance";
881
+            }
882
+            else{
883
+                $new_upgrade->description = $new_upgrade->description." Silent Upgrade was used to upgrade the instance.";
884
+            }
885
+            $new_upgrade->save();
886
+            set_upgrade_progress('commit','in_progress','upgradeHistory','done');
887
+            set_upgrade_progress('commit','done','commit','done');
888
+        }
889
+        }
890
+
891
+    //Clean modules from cache
892
+        $cachedir = sugar_cached('smarty');
893
+        if(is_dir($cachedir)){
894
+            $allModFiles = array();
895
+            $allModFiles = findAllFiles($cachedir,$allModFiles);
896
+            foreach($allModFiles as $file){
897
+                    //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
898
+                    if(file_exists($file)){
899
+                    unlink($file);
900
+                    }
901
+            }
902
+        }
903
+    //delete cache/modules before rebuilding the relations
904
+        //Clean modules from cache
905
+            $cachedir = sugar_cached('modules');
906
+        if(is_dir($cachedir)){
907
+            $allModFiles = array();
908
+            $allModFiles = findAllFiles($cachedir,$allModFiles);
909
+            foreach($allModFiles as $file){
910
+                    //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
911
+                    if(file_exists($file)){
912
+                    unlink($file);
913
+                    }
914
+            }
915
+        }
916
+
917
+        //delete cache/themes
918
+        $cachedir = sugar_cached('themes');
919
+        if(is_dir($cachedir)){
920
+            $allModFiles = array();
921
+            $allModFiles = findAllFiles($cachedir,$allModFiles);
922
+            foreach($allModFiles as $file){
923
+                    //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
924
+                    if(file_exists($file)){
925
+                    unlink($file);
926
+                    }
927
+            }
928
+        }
929
+    ob_start();
930
+    if(!isset($_REQUEST['silent'])){
931
+        $_REQUEST['silent'] = true;
932
+    }
933
+    else if(isset($_REQUEST['silent']) && $_REQUEST['silent'] != true){
934
+        $_REQUEST['silent'] = true;
935
+    }
936
+
937
+        //logThis('Checking for leads_assigned_user relationship and if not found then create.', $path);
938
+    @createMissingRels();
939
+        //logThis('Checked for leads_assigned_user relationship.', $path);
940
+    ob_end_clean();
941
+    //// run fix on dropdown lists that may have been incorrectly named
942 942
     //fix_dropdown_list();
943 943
 }
944 944
 
@@ -947,19 +947,19 @@  discard block
 block discarded – undo
947 947
 ///////////////////////////////////////////////////////////////////////////////
948 948
 
949 949
 if(function_exists('deleteCache')){
950
-	set_upgrade_progress('end','in_progress','deleteCache','in_progress');
951
-	@deleteCache();
952
-	set_upgrade_progress('end','in_progress','deleteCache','done');
950
+    set_upgrade_progress('end','in_progress','deleteCache','in_progress');
951
+    @deleteCache();
952
+    set_upgrade_progress('end','in_progress','deleteCache','done');
953 953
 }
954 954
 
955 955
 ///////////////////////////////////////////////////////////////////////////////
956 956
 ////	HANDLE REMINDERS
957 957
 if(empty($errors)) {
958
-	commitHandleReminders($skippedFiles, $path);
958
+    commitHandleReminders($skippedFiles, $path);
959 959
 }
960 960
 
961 961
 if(file_exists(clean_path(getcwd()).'/original451files')){
962
-	rmdir_recursive(clean_path(getcwd()).'/original451files');
962
+    rmdir_recursive(clean_path(getcwd()).'/original451files');
963 963
 }
964 964
 
965 965
 require_once('modules/Administration/Administration.php');
@@ -995,14 +995,14 @@  discard block
 block discarded – undo
995 995
         }
996 996
 
997 997
         $must_have_modules= array(
998
-			  'Activities'=>'Activities',
999
-        	  'Calendar'=>'Calendar',
1000
-        	  'Reports' => 'Reports',
1001
-			  'Quotes' => 'Quotes',
1002
-			  'Products' => 'Products',
1003
-			  'Forecasts' => 'Forecasts',
1004
-			  'Contracts' => 'Contracts',
1005
-			  'KBDocuments' => 'KBDocuments'
998
+                'Activities'=>'Activities',
999
+                'Calendar'=>'Calendar',
1000
+                'Reports' => 'Reports',
1001
+                'Quotes' => 'Quotes',
1002
+                'Products' => 'Products',
1003
+                'Forecasts' => 'Forecasts',
1004
+                'Contracts' => 'Contracts',
1005
+                'KBDocuments' => 'KBDocuments'
1006 1006
         );
1007 1007
         $newModuleList = array_merge($newModuleList,$must_have_modules);
1008 1008
 
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 
1015 1015
         //add the new tabs to the array
1016 1016
         foreach($newModuleList as $nm ){
1017
-          $tabs[$nm] = $nm;
1017
+            $tabs[$nm] = $nm;
1018 1018
         }
1019 1019
 
1020 1020
         //now assign the modules to system tabs
@@ -1026,36 +1026,36 @@  discard block
 block discarded – undo
1026 1026
 if(isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])){
1027 1027
     if (version_compare($_SESSION['current_db_version'], $_SESSION['target_db_version'], '='))
1028 1028
     {
1029
-	    $_REQUEST['upgradeWizard'] = true;
1030
-	    ob_start();
1031
-			include('include/Smarty/internals/core.write_file.php');
1032
-		ob_end_clean();
1033
-	 	$db =& DBManagerFactory::getInstance();
1034
-		if($ce_to_pro_ent){
1035
-	        //Also set license information
1036
-	        $admin = new Administration();
1037
-			$category = 'license';
1038
-			$value = 0;
1039
-			$admin->saveSetting($category, 'users', $value);
1040
-			$key = array('num_lic_oc','key','expire_date');
1041
-			$value = '';
1042
-			foreach($key as $k){
1043
-				$admin->saveSetting($category, $k, $value);
1044
-			}
1045
-		}
1046
-	}
1029
+        $_REQUEST['upgradeWizard'] = true;
1030
+        ob_start();
1031
+            include('include/Smarty/internals/core.write_file.php');
1032
+        ob_end_clean();
1033
+            $db =& DBManagerFactory::getInstance();
1034
+        if($ce_to_pro_ent){
1035
+            //Also set license information
1036
+            $admin = new Administration();
1037
+            $category = 'license';
1038
+            $value = 0;
1039
+            $admin->saveSetting($category, 'users', $value);
1040
+            $key = array('num_lic_oc','key','expire_date');
1041
+            $value = '';
1042
+            foreach($key as $k){
1043
+                $admin->saveSetting($category, $k, $value);
1044
+            }
1045
+        }
1046
+    }
1047 1047
 }
1048 1048
 
1049
-	$phpErrors = ob_get_contents();
1050
-	ob_end_clean();
1051
-	logThis("**** Potential PHP generated error messages: {$phpErrors}", $path);
1049
+    $phpErrors = ob_get_contents();
1050
+    ob_end_clean();
1051
+    logThis("**** Potential PHP generated error messages: {$phpErrors}", $path);
1052 1052
 
1053
-	if(count($errors) > 0) {
1054
-		foreach($errors as $error) {
1055
-			logThis("****** SilentUpgrade ERROR: {$error}", $path);
1056
-		}
1057
-		echo "FAILED\n";
1058
-	}
1053
+    if(count($errors) > 0) {
1054
+        foreach($errors as $error) {
1055
+            logThis("****** SilentUpgrade ERROR: {$error}", $path);
1056
+        }
1057
+        echo "FAILED\n";
1058
+    }
1059 1059
 
1060 1060
 
1061 1061
 }
@@ -1070,67 +1070,67 @@  discard block
 block discarded – undo
1070 1070
  */
1071 1071
 function repairTableDictionaryExtFile()
1072 1072
 {
1073
-	$tableDictionaryExtDirs = array('custom/Extension/application/Ext/TableDictionary', 'custom/application/Ext/TableDictionary');
1074
-
1075
-	foreach($tableDictionaryExtDirs as $tableDictionaryExt)
1076
-	{
1077
-
1078
-		if(is_dir($tableDictionaryExt) && is_writable($tableDictionaryExt)){
1079
-			$dir = dir($tableDictionaryExt);
1080
-			while(($entry = $dir->read()) !== false)
1081
-			{
1082
-				$entry = $tableDictionaryExt . '/' . $entry;
1083
-				if(is_file($entry) && preg_match('/\.php$/i', $entry) && is_writeable($entry))
1084
-				{
1085
-
1086
-						if(function_exists('sugar_fopen'))
1087
-						{
1088
-							$fp = @sugar_fopen($entry, 'r');
1089
-						} else {
1090
-							$fp = fopen($entry, 'r');
1091
-						}
1092
-
1093
-
1094
-					    if($fp)
1095
-				        {
1096
-				             $altered = false;
1097
-				             $contents = '';
1098
-
1099
-				             while($line = fgets($fp))
1100
-						     {
1101
-						    	if(preg_match('/\s*include\s*\(\s*[\'|\"](.*?)[\"|\']\s*\)\s*;/', $line, $match))
1102
-						    	{
1103
-						    	   if(!file_exists($match[1]))
1104
-						    	   {
1105
-						    	      $altered = true;
1106
-						    	   } else {
1107
-						    	   	  $contents .= $line;
1108
-						    	   }
1109
-						    	} else {
1110
-						    	   $contents .= $line;
1111
-						    	}
1112
-						     }
1113
-
1114
-						     fclose($fp);
1115
-				        }
1116
-
1117
-
1118
-					    if($altered)
1119
-					    {
1120
-							if(function_exists('sugar_fopen'))
1121
-							{
1122
-								$fp = @sugar_fopen($entry, 'w');
1123
-							} else {
1124
-								$fp = fopen($entry, 'w');
1125
-							}
1126
-
1127
-							if($fp && fwrite($fp, $contents))
1128
-							{
1129
-								fclose($fp);
1130
-							}
1131
-					    }
1132
-				} //if
1133
-			} //while
1134
-		} //if
1135
-	}
1073
+    $tableDictionaryExtDirs = array('custom/Extension/application/Ext/TableDictionary', 'custom/application/Ext/TableDictionary');
1074
+
1075
+    foreach($tableDictionaryExtDirs as $tableDictionaryExt)
1076
+    {
1077
+
1078
+        if(is_dir($tableDictionaryExt) && is_writable($tableDictionaryExt)){
1079
+            $dir = dir($tableDictionaryExt);
1080
+            while(($entry = $dir->read()) !== false)
1081
+            {
1082
+                $entry = $tableDictionaryExt . '/' . $entry;
1083
+                if(is_file($entry) && preg_match('/\.php$/i', $entry) && is_writeable($entry))
1084
+                {
1085
+
1086
+                        if(function_exists('sugar_fopen'))
1087
+                        {
1088
+                            $fp = @sugar_fopen($entry, 'r');
1089
+                        } else {
1090
+                            $fp = fopen($entry, 'r');
1091
+                        }
1092
+
1093
+
1094
+                        if($fp)
1095
+                        {
1096
+                                $altered = false;
1097
+                                $contents = '';
1098
+
1099
+                                while($line = fgets($fp))
1100
+                                {
1101
+                                if(preg_match('/\s*include\s*\(\s*[\'|\"](.*?)[\"|\']\s*\)\s*;/', $line, $match))
1102
+                                {
1103
+                                    if(!file_exists($match[1]))
1104
+                                    {
1105
+                                        $altered = true;
1106
+                                    } else {
1107
+                                            $contents .= $line;
1108
+                                    }
1109
+                                } else {
1110
+                                    $contents .= $line;
1111
+                                }
1112
+                                }
1113
+
1114
+                                fclose($fp);
1115
+                        }
1116
+
1117
+
1118
+                        if($altered)
1119
+                        {
1120
+                            if(function_exists('sugar_fopen'))
1121
+                            {
1122
+                                $fp = @sugar_fopen($entry, 'w');
1123
+                            } else {
1124
+                                $fp = fopen($entry, 'w');
1125
+                            }
1126
+
1127
+                            if($fp && fwrite($fp, $contents))
1128
+                            {
1129
+                                fclose($fp);
1130
+                            }
1131
+                        }
1132
+                } //if
1133
+            } //while
1134
+        } //if
1135
+    }
1136 1136
 }
Please login to merge, or discard this patch.
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 //// php.exe -f silentUpgrade.php [Path to Upgrade Package zip] [Path to Log file] [Path to Instance]
43 43
 //// See below the Usage for more details.
44 44
 /////////////////////////////////////////////////////////////////////////////////////////
45
-ini_set('memory_limit',-1);
45
+ini_set('memory_limit', -1);
46 46
 ///////////////////////////////////////////////////////////////////////////////
47 47
 ////	UTILITIES THAT MUST BE LOCAL :(
48 48
 function prepSystemForUpgradeSilent() {
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	global $sugar_config;
52 52
 
53 53
 	// make sure dirs exist
54
-	foreach($subdirs as $subdir) {
55
-		if(!is_dir($sugar_config['upload_dir']."/upgrades/{$subdir}")) {
54
+	foreach ($subdirs as $subdir) {
55
+		if (!is_dir($sugar_config['upload_dir']."/upgrades/{$subdir}")) {
56 56
 	    	mkdir_recursive($sugar_config['upload_dir']."/upgrades/{$subdir}");
57 57
 		}
58 58
 	}
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 	if ($current = @opendir($thedir)) {
64 64
 		while (false !== ($children = readdir($current))) {
65 65
 			if ($children != "." && $children != "..") {
66
-				if (is_dir($thedir . "/" . $children)) {
67
-					clearCacheSU($thedir . "/" . $children, $extension);
66
+				if (is_dir($thedir."/".$children)) {
67
+					clearCacheSU($thedir."/".$children, $extension);
68 68
 				}
69
-				elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
70
-					unlink($thedir . "/" . $children);
69
+				elseif (is_file($thedir."/".$children) && substr_count($children, $extension)) {
70
+					unlink($thedir."/".$children);
71 71
 				}
72 72
 			}
73 73
 		}
@@ -75,34 +75,34 @@  discard block
 block discarded – undo
75 75
  }
76 76
  //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
77 77
  //no found then adds default_permissions to the config file.
78
- function checkConfigForPermissions(){
79
-     if(file_exists(getcwd().'/config.php')){
78
+ function checkConfigForPermissions() {
79
+     if (file_exists(getcwd().'/config.php')) {
80 80
          require(getcwd().'/config.php');
81 81
      }
82 82
      global $sugar_config;
83
-     if(!isset($sugar_config['default_permissions'])){
84
-             $sugar_config['default_permissions'] = array (
83
+     if (!isset($sugar_config['default_permissions'])) {
84
+             $sugar_config['default_permissions'] = array(
85 85
                      'dir_mode' => 02770,
86 86
                      'file_mode' => 0660,
87 87
                      'user' => '',
88 88
                      'group' => '',
89 89
              );
90 90
          ksort($sugar_config);
91
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
91
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
92 92
         	//writing to the file
93 93
  		}
94 94
      }
95 95
 }
96
-function checkLoggerSettings(){
97
-	if(file_exists(getcwd().'/config.php')){
96
+function checkLoggerSettings() {
97
+	if (file_exists(getcwd().'/config.php')) {
98 98
          require(getcwd().'/config.php');
99 99
      }
100 100
     global $sugar_config;
101
-	if(!isset($sugar_config['logger'])){
102
-	    $sugar_config['logger'] =array (
101
+	if (!isset($sugar_config['logger'])) {
102
+	    $sugar_config['logger'] = array(
103 103
 			'level'=>'fatal',
104 104
 		    'file' =>
105
-		     array (
105
+		     array(
106 106
 		      'ext' => '.log',
107 107
 		      'name' => 'sugarcrm',
108 108
 		      'dateFormat' => '%c',
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		    ),
113 113
 		  );
114 114
 		 ksort($sugar_config);
115
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
115
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
116 116
         	//writing to the file
117 117
  		}
118 118
 	 }
@@ -126,23 +126,23 @@  discard block
 block discarded – undo
126 126
     if (!isset($sugar_config['lead_conv_activity_opt'])) {
127 127
         $sugar_config['lead_conv_activity_opt'] = 'copy';
128 128
         ksort($sugar_config);
129
-        if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
129
+        if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
130 130
             //writing to the file
131 131
         }
132 132
     }
133 133
 }
134 134
 
135
-function checkResourceSettings(){
136
-	if(file_exists(getcwd().'/config.php')){
135
+function checkResourceSettings() {
136
+	if (file_exists(getcwd().'/config.php')) {
137 137
          require(getcwd().'/config.php');
138 138
      }
139 139
     global $sugar_config;
140
-	if(!isset($sugar_config['resource_management'])){
140
+	if (!isset($sugar_config['resource_management'])) {
141 141
 	  $sugar_config['resource_management'] =
142
-		  array (
142
+		  array(
143 143
 		    'special_query_limit' => 50000,
144 144
 		    'special_query_modules' =>
145
-		    array (
145
+		    array(
146 146
 		      0 => 'Reports',
147 147
 		      1 => 'Export',
148 148
 		      2 => 'Import',
@@ -152,23 +152,23 @@  discard block
 block discarded – undo
152 152
 		    'default_limit' => 1000,
153 153
 		  );
154 154
 		 ksort($sugar_config);
155
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
155
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
156 156
         	//writing to the file
157 157
  		}
158 158
 	}
159 159
 }
160 160
 
161 161
 
162
-function createMissingRels(){
163
-	$relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
164
-	foreach($relForObjects as $relObjName=>$relModName){
162
+function createMissingRels() {
163
+	$relForObjects = array('leads'=>'Leads', 'campaigns'=>'Campaigns', 'prospects'=>'Prospects');
164
+	foreach ($relForObjects as $relObjName=>$relModName) {
165 165
 		//assigned_user
166 166
 		$guid = create_guid();
167 167
 		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
168
-		$result= $GLOBALS['db']->query($query, true);
168
+		$result = $GLOBALS['db']->query($query, true);
169 169
 		$a = null;
170 170
 		$a = $GLOBALS['db']->fetchByAssoc($result);
171
-		if(!isset($a['id']) && empty($a['id']) ){
171
+		if (!isset($a['id']) && empty($a['id'])) {
172 172
 			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
173 173
 						VALUES ('{$guid}', '{$relObjName}_assigned_user','Users','users','id','{$relModName}','{$relObjName}','assigned_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
174 174
 			$GLOBALS['db']->query($qRel);
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 		//modified_user
177 177
 		$guid = create_guid();
178 178
 		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
179
-		$result= $GLOBALS['db']->query($query, true);
179
+		$result = $GLOBALS['db']->query($query, true);
180 180
 		$a = null;
181 181
 		$a = $GLOBALS['db']->fetchByAssoc($result);
182
-		if(!isset($a['id']) && empty($a['id']) ){
182
+		if (!isset($a['id']) && empty($a['id'])) {
183 183
 			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
184 184
 						VALUES ('{$guid}', '{$relObjName}_modified_user','Users','users','id','{$relModName}','{$relObjName}','modified_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
185 185
 			$GLOBALS['db']->query($qRel);
@@ -187,20 +187,20 @@  discard block
 block discarded – undo
187 187
 		//created_by
188 188
 		$guid = create_guid();
189 189
 		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
190
-		$result= $GLOBALS['db']->query($query, true);
190
+		$result = $GLOBALS['db']->query($query, true);
191 191
 		$a = null;
192 192
 		$a = $GLOBALS['db']->fetchByAssoc($result);
193
-    	if(!isset($a['id']) && empty($a['id']) ){
193
+    	if (!isset($a['id']) && empty($a['id'])) {
194 194
 			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
195 195
 						VALUES ('{$guid}', '{$relObjName}_created_by','Users','users','id','{$relModName}','{$relObjName}','created_by',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
196 196
 			$GLOBALS['db']->query($qRel);
197 197
     	}
198 198
 		$guid = create_guid();
199 199
 		$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_team'";
200
-		$result= $GLOBALS['db']->query($query, true);
200
+		$result = $GLOBALS['db']->query($query, true);
201 201
 		$a = null;
202 202
 		$a = $GLOBALS['db']->fetchByAssoc($result);
203
-		if(!isset($a['id']) && empty($a['id']) ){
203
+		if (!isset($a['id']) && empty($a['id'])) {
204 204
 			$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
205 205
 							VALUES ('{$guid}', '{$relObjName}_team','Teams','teams','id','{$relModName}','{$relObjName}','team_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
206 206
 			$GLOBALS['db']->query($qRel);
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
 	//Also add tracker perf relationship
210 210
 	$guid = create_guid();
211 211
 	$query = "SELECT id FROM relationships WHERE relationship_name = 'tracker_monitor_id'";
212
-	$result= $GLOBALS['db']->query($query, true);
212
+	$result = $GLOBALS['db']->query($query, true);
213 213
 	$a = null;
214 214
 	$a = $GLOBALS['db']->fetchByAssoc($result);
215
-	if(!isset($a['id']) && empty($a['id']) ){
215
+	if (!isset($a['id']) && empty($a['id'])) {
216 216
 		$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
217 217
 					VALUES ('{$guid}', 'tracker_monitor_id','TrackerPerfs','tracker_perf','monitor_id','Trackers','tracker','monitor_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
218 218
 		$GLOBALS['db']->query($qRel);
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
  */
229 229
 function merge_passwordsetting($sugar_config, $sugar_version) {
230 230
 
231
-     $passwordsetting_defaults = array (
232
-        'passwordsetting' => array (
231
+     $passwordsetting_defaults = array(
232
+        'passwordsetting' => array(
233 233
             'minpwdlength' => '',
234 234
             'maxpwdlength' => '',
235 235
             'oneupper' => '',
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
         ),
261 261
     );
262 262
 
263
-    $sugar_config = sugarArrayMerge($passwordsetting_defaults, $sugar_config );
263
+    $sugar_config = sugarArrayMerge($passwordsetting_defaults, $sugar_config);
264 264
 
265 265
     // need to override version with default no matter what
266 266
     $sugar_config['sugar_version'] = $sugar_version;
267 267
 
268
-    ksort( $sugar_config );
268
+    ksort($sugar_config);
269 269
 
270
-    if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
270
+    if (write_array_to_file("sugar_config", $sugar_config, "config.php")) {
271 271
         return true;
272 272
     }
273 273
     else {
@@ -276,17 +276,17 @@  discard block
 block discarded – undo
276 276
 }
277 277
 
278 278
 function addDefaultModuleRoles($defaultRoles = array()) {
279
-	foreach($defaultRoles as $roleName=>$role){
280
-        foreach($role as $category=>$actions){
281
-            foreach($actions as $name=>$access_override){
279
+	foreach ($defaultRoles as $roleName=>$role) {
280
+        foreach ($role as $category=>$actions) {
281
+            foreach ($actions as $name=>$access_override) {
282 282
                     $query = "SELECT * FROM acl_actions WHERE name='$name' AND category = '$category' AND acltype='$roleName' AND deleted=0 ";
283 283
 					$result = $GLOBALS['db']->query($query);
284 284
 					//only add if an action with that name and category don't exist
285
-					$row=$GLOBALS['db']->fetchByAssoc($result);
285
+					$row = $GLOBALS['db']->fetchByAssoc($result);
286 286
 					if ($row == null) {
287 287
 	                	$guid = create_guid();
288 288
 	                	$currdate = gmdate('Y-m-d H:i:s');
289
-	                	$query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
289
+	                	$query = "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
290 290
 						$GLOBALS['db']->query($query);
291 291
 	                }
292 292
             }
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 	}
295 295
 }
296 296
 
297
-function verifyArguments($argv,$usage_regular){
297
+function verifyArguments($argv, $usage_regular) {
298 298
     $upgradeType = '';
299 299
     $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
300
-    if(isset($argv[3])) {
301
-        if(is_dir($argv[3])) {
300
+    if (isset($argv[3])) {
301
+        if (is_dir($argv[3])) {
302 302
             $cwd = $argv[3];
303 303
             chdir($cwd);
304 304
         } else {
@@ -308,18 +308,18 @@  discard block
 block discarded – undo
308 308
         }
309 309
     }
310 310
 
311
-    if(is_file("{$cwd}/include/entryPoint.php")) {
311
+    if (is_file("{$cwd}/include/entryPoint.php")) {
312 312
         //this should be a regular sugar install
313 313
         $upgradeType = constant('SUGARCRM_INSTALL');
314 314
         //check if this is a valid zip file
315
-        if(!is_file($argv[1])) { // valid zip?
315
+        if (!is_file($argv[1])) { // valid zip?
316 316
             echo "*******************************************************************************\n";
317 317
             echo "*** ERROR: First argument must be a full path to the patch file. Got [ {$argv[1]} ].\n";
318 318
             echo $usage_regular;
319 319
             echo "FAILURE\n";
320 320
             exit(1);
321 321
         }
322
-        if(count($argv) < 5) {
322
+        if (count($argv) < 5) {
323 323
             echo "*******************************************************************************\n";
324 324
             echo "*** ERROR: Missing required parameters.  Received ".count($argv)." argument(s), require 5.\n";
325 325
             echo $usage_regular;
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
         exit(1);
334 334
     }
335 335
 
336
-    if(isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')){
336
+    if (isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')) {
337 337
         require_once($argv[7].'SugarTemplateUtilties.php');
338 338
     }
339 339
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 
343 343
 
344 344
 
345
-function threeWayMerge(){
345
+function threeWayMerge() {
346 346
 	//using threeway merge apis
347 347
 }
348 348
 
@@ -357,14 +357,14 @@  discard block
 block discarded – undo
357 357
 //End of #52872
358 358
 
359 359
 // only run from command line
360
-if(isset($_SERVER['HTTP_USER_AGENT'])) {
361
-	fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
360
+if (isset($_SERVER['HTTP_USER_AGENT'])) {
361
+	fwrite(STDERR, 'This utility may only be run from the command line or command prompt.');
362 362
 	exit(1);
363 363
 }
364 364
 //Clean_string cleans out any file  passed in as a parameter
365 365
 $_SERVER['PHP_SELF'] = 'silentUpgrade.php';
366 366
 
367
-$usage_regular =<<<eoq2
367
+$usage_regular = <<<eoq2
368 368
 Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance] [admin-user]
369 369
 
370 370
 On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 
387 387
 ///////////////////////////////////////////////////////////////////////////////
388 388
 ////	STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
389
-if(!defined('sugarEntry')) define('sugarEntry', true);
389
+if (!defined('sugarEntry')) define('sugarEntry', true);
390 390
 
391 391
 $_SESSION = array();
392 392
 $_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
 global $cwd;
404 404
 $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
405 405
 
406
-$upgradeType = verifyArguments($argv,$usage_regular);
406
+$upgradeType = verifyArguments($argv, $usage_regular);
407 407
 
408 408
 ///////////////////////////////////////////////////////////////////////////////
409 409
 //////  Verify that all the arguments are appropriately placed////////////////
410 410
 
411
-$path			= $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
412
-$subdirs		= array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
411
+$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
412
+$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
413 413
 
414 414
 //$_REQUEST['zip_from_dir'] = $zip_from_dir;
415 415
 
@@ -431,15 +431,15 @@  discard block
 block discarded – undo
431 431
 $errors = array();
432 432
 
433 433
 
434
-if($upgradeType != constant('DCE_INSTANCE')) {
434
+if ($upgradeType != constant('DCE_INSTANCE')) {
435 435
 
436
-	ini_set('error_reporting',1);
436
+	ini_set('error_reporting', 1);
437 437
 	require_once('include/entryPoint.php');
438 438
 	require_once('include/SugarLogger/SugarLogger.php');
439 439
 	require_once('include/utils/zip_utils.php');
440 440
 
441 441
 
442
-if(!function_exists('sugar_cached'))
442
+if (!function_exists('sugar_cached'))
443 443
 {
444 444
     /**
445 445
      * sugar_cached
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
     function sugar_cached($file)
451 451
     {
452 452
         static $cdir = null;
453
-        if(empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) {
453
+        if (empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) {
454 454
             $cdir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\');
455 455
         }
456
-        if(empty($cdir)) {
456
+        if (empty($cdir)) {
457 457
             $cdir = "cache";
458 458
         }
459 459
         return "$cdir/$file";
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 
463 463
 	require('config.php');
464 464
 	//require_once('modules/UpgradeWizard/uw_utils.php'); // must upgrade UW first
465
-	if(isset($argv[3])) {
466
-		if(is_dir($argv[3])) {
465
+	if (isset($argv[3])) {
466
+		if (is_dir($argv[3])) {
467 467
 			$cwd = $argv[3];
468 468
 			chdir($cwd);
469 469
 		}
@@ -471,37 +471,37 @@  discard block
 block discarded – undo
471 471
 
472 472
 	require_once("{$cwd}/sugar_version.php"); // provides $sugar_version & $sugar_flavor
473 473
 
474
-    $GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
475
-	$patchName		= basename($argv[1]);
476
-	$zip_from_dir	= substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip")
477
-	$path			= $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
474
+    $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
475
+	$patchName = basename($argv[1]);
476
+	$zip_from_dir = substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip")
477
+	$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
478 478
 
479
-    $db				= &DBManagerFactory::getInstance();
480
-	$UWstrings		= return_module_language('en_us', 'UpgradeWizard');
481
-	$adminStrings	= return_module_language('en_us', 'Administration');
479
+    $db = &DBManagerFactory::getInstance();
480
+	$UWstrings = return_module_language('en_us', 'UpgradeWizard');
481
+	$adminStrings = return_module_language('en_us', 'Administration');
482 482
     $app_list_strings = return_app_list_strings_language('en_us');
483
-	$mod_strings	= array_merge($adminStrings, $UWstrings);
484
-	$subdirs		= array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
483
+	$mod_strings = array_merge($adminStrings, $UWstrings);
484
+	$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
485 485
 	global $unzip_dir;
486 486
     $license_accepted = false;
487
-    if(isset($argv[5]) && (strtolower($argv[5])=='yes' || strtolower($argv[5])=='y')){
487
+    if (isset($argv[5]) && (strtolower($argv[5]) == 'yes' || strtolower($argv[5]) == 'y')) {
488 488
     	$license_accepted = true;
489 489
 	 }
490 490
 	//////////////////////////////////////////////////////////////////////////////
491 491
 	//Adding admin user to the silent upgrade
492 492
 
493 493
 	$current_user = new User();
494
-	if(isset($argv[4])) {
494
+	if (isset($argv[4])) {
495 495
 	   //if being used for internal upgrades avoid admin user verification
496 496
 	   $user_name = $argv[4];
497
-	   $q = "select id from users where user_name = '" . $user_name . "' and is_admin=1";
497
+	   $q = "select id from users where user_name = '".$user_name."' and is_admin=1";
498 498
 	   $result = $GLOBALS['db']->query($q, false);
499 499
 	   $logged_user = $GLOBALS['db']->fetchByAssoc($result);
500
-	   if(isset($logged_user['id']) && $logged_user['id'] != null){
500
+	   if (isset($logged_user['id']) && $logged_user['id'] != null) {
501 501
 		//do nothing
502 502
 	    $current_user->retrieve($logged_user['id']);
503 503
 	   }
504
-	   else{
504
+	   else {
505 505
 	   	echo "FAILURE: Not an admin user in users table. Please provide an admin user\n";
506 506
 		exit(1);
507 507
 	   }
@@ -533,18 +533,18 @@  discard block
 block discarded – undo
533 533
 $_SESSION['unzip_dir'] = $unzip_dir;
534 534
 $_SESSION['install_file'] = $install_file;
535 535
 $_SESSION['zip_from_dir'] = $zip_from_dir;
536
-if(is_dir($unzip_dir.'/scripts'))
536
+if (is_dir($unzip_dir.'/scripts'))
537 537
 {
538 538
 	rmdir_recursive($unzip_dir.'/scripts');
539 539
 }
540
-if(is_file($unzip_dir.'/manifest.php'))
540
+if (is_file($unzip_dir.'/manifest.php'))
541 541
 {
542 542
 	rmdir_recursive($unzip_dir.'/manifest.php');
543 543
 }
544 544
 mkdir_recursive($unzip_dir);
545
-if(!is_dir($unzip_dir)) {
545
+if (!is_dir($unzip_dir)) {
546 546
 	echo "\n{$unzip_dir} is not an available directory\nFAILURE\n";
547
-	fwrite(STDERR,"\n{$unzip_dir} is not an available directory\nFAILURE\n");
547
+	fwrite(STDERR, "\n{$unzip_dir} is not an available directory\nFAILURE\n");
548 548
 	exit(1);
549 549
 }
550 550
 
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 $uwFiles = findAllFiles("{$zipBasePath}/modules/UpgradeWizard", array());
562 562
 $destFiles = array();
563 563
 
564
-foreach($uwFiles as $uwFile) {
564
+foreach ($uwFiles as $uwFile) {
565 565
 	$destFile = str_replace($zipBasePath."/", '', $uwFile);
566 566
 	copy($uwFile, $destFile);
567 567
 }
@@ -570,17 +570,17 @@  discard block
 block discarded – undo
570 570
 logThis("*** SILENT UPGRADE INITIATED.", $path);
571 571
 logThis("*** UpgradeWizard Upgraded  ", $path);
572 572
 
573
-if(function_exists('set_upgrade_vars')){
573
+if (function_exists('set_upgrade_vars')) {
574 574
 	set_upgrade_vars();
575 575
 }
576 576
 
577
-if($configOptions['db_type'] == 'mysql'){
577
+if ($configOptions['db_type'] == 'mysql') {
578 578
 	//Change the db wait_timeout for this session
579 579
 	$now_timeout = $db->getOne("select @@wait_timeout");
580
-	logThis('Wait Timeout before change ***** '.$now_timeout , $path);
580
+	logThis('Wait Timeout before change ***** '.$now_timeout, $path);
581 581
 	$db->query("set wait_timeout=28800");	
582 582
 	$now_timeout = $db->getOne("select @@wait_timeout");	
583
-	logThis('Wait Timeout after change ***** '.$now_timeout , $path);
583
+	logThis('Wait Timeout after change ***** '.$now_timeout, $path);
584 584
 }
585 585
 
586 586
 ////	END UPGRADE UPGRADEWIZARD
@@ -588,24 +588,24 @@  discard block
 block discarded – undo
588 588
 
589 589
 ///////////////////////////////////////////////////////////////////////////////
590 590
 ////	MAKE SURE PATCH IS COMPATIBLE
591
-if(is_file("$unzip_dir/manifest.php")) {
591
+if (is_file("$unzip_dir/manifest.php")) {
592 592
 	// provides $manifest array
593 593
 	include("$unzip_dir/manifest.php");
594
-	if(!isset($manifest)) {
595
-		fwrite(STDERR,"\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
594
+	if (!isset($manifest)) {
595
+		fwrite(STDERR, "\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
596 596
 	    exit(1);
597 597
 	} else {
598 598
 		copy("$unzip_dir/manifest.php", $sugar_config['upload_dir']."/upgrades/patch/{$zip_from_dir}-manifest.php");
599 599
 
600 600
 		$error = validate_manifest($manifest);
601
-		if(!empty($error)) {
601
+		if (!empty($error)) {
602 602
 			$error = strip_tags(br2nl($error));
603
-			fwrite(STDERR,"\n{$error}\n\nFAILURE\n");
603
+			fwrite(STDERR, "\n{$error}\n\nFAILURE\n");
604 604
 			exit(1);
605 605
 		}
606 606
 	}
607 607
 } else {
608
-	fwrite(STDERR,"\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
608
+	fwrite(STDERR, "\nThe patch did not contain a proper manifest.php file.  Cannot continue.\n\n");
609 609
 	exit(1);
610 610
 }
611 611
 
@@ -623,17 +623,17 @@  discard block
 block discarded – undo
623 623
 ////	RUN SILENT UPGRADE
624 624
 ob_start();
625 625
 set_time_limit(0);
626
-if(file_exists('ModuleInstall/PackageManager/PackageManagerDisplay.php')) {
626
+if (file_exists('ModuleInstall/PackageManager/PackageManagerDisplay.php')) {
627 627
 	require_once('ModuleInstall/PackageManager/PackageManagerDisplay.php');
628 628
 }
629 629
 
630 630
 
631 631
 	//copy minimum required files including sugar_file_utils.php
632
-	if(file_exists("{$zipBasePath}/include/utils/sugar_file_utils.php")){
632
+	if (file_exists("{$zipBasePath}/include/utils/sugar_file_utils.php")) {
633 633
 		$destFile = clean_path(str_replace($zipBasePath, $cwd, "{$zipBasePath}/include/utils/sugar_file_utils.php"));
634 634
 		copy("{$zipBasePath}/include/utils/sugar_file_utils.php", $destFile);
635 635
 	}
636
-	if(file_exists('include/utils/sugar_file_utils.php')){
636
+	if (file_exists('include/utils/sugar_file_utils.php')) {
637 637
     	require_once('include/utils/sugar_file_utils.php');
638 638
     }
639 639
 
@@ -648,60 +648,60 @@  discard block
 block discarded – undo
648 648
 }
649 649
 */
650 650
 //If version less than 500 then look for modules to be upgraded
651
-if(function_exists('set_upgrade_vars')){
651
+if (function_exists('set_upgrade_vars')) {
652 652
 	set_upgrade_vars();
653 653
 }
654 654
 //Initialize the session variables. If upgrade_progress.php is already created
655 655
 //look for session vars there and restore them
656
-if(function_exists('initialize_session_vars')){
656
+if (function_exists('initialize_session_vars')) {
657 657
 	initialize_session_vars();
658 658
 }
659 659
 
660
-if(!didThisStepRunBefore('preflight')){
661
-	set_upgrade_progress('preflight','in_progress');
660
+if (!didThisStepRunBefore('preflight')) {
661
+	set_upgrade_progress('preflight', 'in_progress');
662 662
 	//Quickcreatedefs on the basis of editviewdefs
663 663
     updateQuickCreateDefs();
664
-	set_upgrade_progress('preflight','done');
664
+	set_upgrade_progress('preflight', 'done');
665 665
 }
666 666
 ////////////////COMMIT PROCESS BEGINS///////////////////////////////////////////////////////////////
667 667
 ////	MAKE BACKUPS OF TARGET FILES
668 668
 
669
-if(!didThisStepRunBefore('commit')){
670
-	set_upgrade_progress('commit','in_progress','commit','in_progress');
671
-	if(!didThisStepRunBefore('commit','commitMakeBackupFiles')){
672
-		set_upgrade_progress('commit','in_progress','commitMakeBackupFiles','in_progress');
669
+if (!didThisStepRunBefore('commit')) {
670
+	set_upgrade_progress('commit', 'in_progress', 'commit', 'in_progress');
671
+	if (!didThisStepRunBefore('commit', 'commitMakeBackupFiles')) {
672
+		set_upgrade_progress('commit', 'in_progress', 'commitMakeBackupFiles', 'in_progress');
673 673
 		$errors = commitMakeBackupFiles($rest_dir, $install_file, $unzip_dir, $zip_from_dir, array());
674
-		set_upgrade_progress('commit','in_progress','commitMakeBackupFiles','done');
674
+		set_upgrade_progress('commit', 'in_progress', 'commitMakeBackupFiles', 'done');
675 675
 	}
676 676
 
677 677
 	//Need to make sure we have the matching copy of SetValueAction for static/instance method matching
678
-    if(file_exists("include/Expressions/Actions/SetValueAction.php")){
678
+    if (file_exists("include/Expressions/Actions/SetValueAction.php")) {
679 679
         require_once("include/Expressions/Actions/SetValueAction.php");
680 680
     }
681 681
 
682 682
 	///////////////////////////////////////////////////////////////////////////////
683 683
 	////	HANDLE PREINSTALL SCRIPTS
684
-	if(empty($errors)) {
684
+	if (empty($errors)) {
685 685
 		$file = "{$unzip_dir}/".constant('SUGARCRM_PRE_INSTALL_FILE');
686 686
 
687
-		if(is_file($file)) {
687
+		if (is_file($file)) {
688 688
 			include($file);
689
-			if(!didThisStepRunBefore('commit','pre_install')){
690
-				set_upgrade_progress('commit','in_progress','pre_install','in_progress');
689
+			if (!didThisStepRunBefore('commit', 'pre_install')) {
690
+				set_upgrade_progress('commit', 'in_progress', 'pre_install', 'in_progress');
691 691
 				pre_install();
692
-				set_upgrade_progress('commit','in_progress','pre_install','done');
692
+				set_upgrade_progress('commit', 'in_progress', 'pre_install', 'done');
693 693
 			}
694 694
 		}
695 695
 	}
696 696
 
697 697
 	//Clean smarty from cache
698 698
 	$cachedir = sugar_cached('smarty');
699
-	if(is_dir($cachedir)){
699
+	if (is_dir($cachedir)) {
700 700
 		$allModFiles = array();
701
-		$allModFiles = findAllFiles($cachedir,$allModFiles);
702
-	   foreach($allModFiles as $file){
701
+		$allModFiles = findAllFiles($cachedir, $allModFiles);
702
+	   foreach ($allModFiles as $file) {
703 703
 	       	//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
704
-	       	if(file_exists($file)){
704
+	       	if (file_exists($file)) {
705 705
 				unlink($file);
706 706
 	       	}
707 707
 	   }
@@ -709,29 +709,29 @@  discard block
 block discarded – undo
709 709
 
710 710
 		//Also add the three-way merge here. The idea is after the 451 html files have
711 711
 		//been converted run the 3-way merge. If 500 then just run the 3-way merge
712
-		if(file_exists('modules/UpgradeWizard/SugarMerge/SugarMerge.php')){
713
-		    set_upgrade_progress('end','in_progress','threewaymerge','in_progress');
712
+		if (file_exists('modules/UpgradeWizard/SugarMerge/SugarMerge.php')) {
713
+		    set_upgrade_progress('end', 'in_progress', 'threewaymerge', 'in_progress');
714 714
 		    require_once('modules/UpgradeWizard/SugarMerge/SugarMerge.php');
715 715
 		    $merger = new SugarMerge($zipBasePath);
716 716
 		    $merger->mergeAll();
717
-		    set_upgrade_progress('end','in_progress','threewaymerge','done');
717
+		    set_upgrade_progress('end', 'in_progress', 'threewaymerge', 'done');
718 718
 		}
719 719
 	///////////////////////////////////////////////////////////////////////////////
720 720
 	////	COPY NEW FILES INTO TARGET INSTANCE
721 721
 
722
-     if(!didThisStepRunBefore('commit','commitCopyNewFiles')){
723
-			set_upgrade_progress('commit','in_progress','commitCopyNewFiles','in_progress');
722
+     if (!didThisStepRunBefore('commit', 'commitCopyNewFiles')) {
723
+			set_upgrade_progress('commit', 'in_progress', 'commitCopyNewFiles', 'in_progress');
724 724
 			$split = commitCopyNewFiles($unzip_dir, $zip_from_dir);
725 725
 	 		$copiedFiles = $split['copiedFiles'];
726 726
 	 		$skippedFiles = $split['skippedFiles'];
727
-			set_upgrade_progress('commit','in_progress','commitCopyNewFiles','done');
727
+			set_upgrade_progress('commit', 'in_progress', 'commitCopyNewFiles', 'done');
728 728
 	 }
729 729
 	require_once(clean_path($unzip_dir.'/scripts/upgrade_utils.php'));
730 730
 	$new_sugar_version = getUpgradeVersion();
731 731
     $siv_varset_1 = setSilentUpgradeVar('origVersion', $sugar_version);
732 732
     $siv_varset_2 = setSilentUpgradeVar('destVersion', $new_sugar_version);
733 733
     $siv_write    = writeSilentUpgradeVars();
734
-    if(!$siv_varset_1 || !$siv_varset_2 || !$siv_write){
734
+    if (!$siv_varset_1 || !$siv_varset_2 || !$siv_write) {
735 735
         logThis("Error with silent upgrade variables: origVersion write success is ({$siv_varset_1}) ".
736 736
         		"-- destVersion write success is ({$siv_varset_2}) -- ".
737 737
         		"writeSilentUpgradeVars success is ({$siv_write}) -- ".
@@ -754,29 +754,29 @@  discard block
 block discarded – undo
754 754
     }
755 755
 	///////////////////////////////////////////////////////////////////////////////
756 756
 	////	HANDLE POSTINSTALL SCRIPTS
757
-	if(empty($errors)) {
757
+	if (empty($errors)) {
758 758
 		logThis('Starting post_install()...', $path);
759 759
 
760 760
 		$trackerManager = TrackerManager::getInstance();
761 761
         $trackerManager->pause();
762 762
         $trackerManager->unsetMonitors();
763 763
 
764
-		if(!didThisStepRunBefore('commit','post_install')){
765
-			$file = "$unzip_dir/" . constant('SUGARCRM_POST_INSTALL_FILE');
766
-			if(is_file($file)) {
764
+		if (!didThisStepRunBefore('commit', 'post_install')) {
765
+			$file = "$unzip_dir/".constant('SUGARCRM_POST_INSTALL_FILE');
766
+			if (is_file($file)) {
767 767
 				//set_upgrade_progress('commit','in_progress','post_install','in_progress');
768
-				$progArray['post_install']='in_progress';
769
-				post_install_progress($progArray,'set');
768
+				$progArray['post_install'] = 'in_progress';
769
+				post_install_progress($progArray, 'set');
770 770
 				    global $moduleList;
771 771
 					include($file);
772 772
 					post_install();
773 773
 				// cn: only run conversion if admin selects "Sugar runs SQL"
774
-				if(!empty($_SESSION['allTables']) && $_SESSION['schema_change'] == 'sugar')
774
+				if (!empty($_SESSION['allTables']) && $_SESSION['schema_change'] == 'sugar')
775 775
 					executeConvertTablesSql($_SESSION['allTables']);
776 776
 				//set process to done
777
-				$progArray['post_install']='done';
777
+				$progArray['post_install'] = 'done';
778 778
 				//set_upgrade_progress('commit','in_progress','post_install','done');
779
-				post_install_progress($progArray,'set');
779
+				post_install_progress($progArray, 'set');
780 780
 			}
781 781
 		}
782 782
 	    //clean vardefs
@@ -807,19 +807,19 @@  discard block
 block discarded – undo
807 807
 		require('config.php');
808 808
 		global $sugar_config;
809 809
 
810
-		if($ce_to_pro_ent){
811
-			if(isset($sugar_config['sugarbeet']))
810
+		if ($ce_to_pro_ent) {
811
+			if (isset($sugar_config['sugarbeet']))
812 812
 			{
813 813
 			    //$sugar_config['sugarbeet'] is only set in COMM
814 814
 			    unset($sugar_config['sugarbeet']);
815 815
 			}
816
-		    if(isset($sugar_config['disable_team_access_check']))
816
+		    if (isset($sugar_config['disable_team_access_check']))
817 817
 			{
818 818
 			    //$sugar_config['disable_team_access_check'] is a runtime configration,
819 819
 			    //no need to write to config.php
820 820
 			    unset($sugar_config['disable_team_access_check']);
821 821
 			}
822
-			if(!merge_passwordsetting($sugar_config, $sugar_version)) {
822
+			if (!merge_passwordsetting($sugar_config, $sugar_version)) {
823 823
 				logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
824 824
 				$errors[] = 'Could not write config.php!';
825 825
 			}
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 		logThis('Set default_theme to Sugar', $path);
830 830
 		$sugar_config['default_theme'] = 'Sugar';
831 831
 
832
-		if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) {
832
+		if (!write_array_to_file("sugar_config", $sugar_config, "config.php")) {
833 833
             logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
834 834
             $errors[] = 'Could not write config.php!';
835 835
         }
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
         logThis('Set default_max_tabs to 7', $path);
838 838
 		$sugar_config['default_max_tabs'] = '7';
839 839
 
840
-		if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) {
840
+		if (!write_array_to_file("sugar_config", $sugar_config, "config.php")) {
841 841
             logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
842 842
             $errors[] = 'Could not write config.php!';
843 843
         }
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
         logThis('Upgrade the sugar_version', $path);
851 851
         $sugar_config['sugar_version'] = $sugar_version;
852 852
 
853
-        if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) {
853
+        if (!write_array_to_file("sugar_config", $sugar_config, "config.php")) {
854 854
             logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
855 855
             $errors[] = 'Could not write config.php!';
856 856
         }
@@ -860,10 +860,10 @@  discard block
 block discarded – undo
860 860
 
861 861
 	///////////////////////////////////////////////////////////////////////////////
862 862
 	////	REGISTER UPGRADE
863
-	if(empty($errors)) {
863
+	if (empty($errors)) {
864 864
 		logThis('Registering upgrade with UpgradeHistory', $path);
865
-		if(!didThisStepRunBefore('commit','upgradeHistory')){
866
-			set_upgrade_progress('commit','in_progress','upgradeHistory','in_progress');
865
+		if (!didThisStepRunBefore('commit', 'upgradeHistory')) {
866
+			set_upgrade_progress('commit', 'in_progress', 'upgradeHistory', 'in_progress');
867 867
 			$file_action = "copied";
868 868
 			// if error was encountered, script should have died before now
869 869
 			$new_upgrade = new UpgradeHistory();
@@ -876,26 +876,26 @@  discard block
 block discarded – undo
876 876
 			$new_upgrade->status = "installed";
877 877
 			$new_upgrade->manifest = (!empty($_SESSION['install_manifest']) ? $_SESSION['install_manifest'] : '');
878 878
 
879
-			if($new_upgrade->description == null){
879
+			if ($new_upgrade->description == null) {
880 880
 				$new_upgrade->description = "Silent Upgrade was used to upgrade the instance";
881 881
 			}
882
-			else{
882
+			else {
883 883
 				$new_upgrade->description = $new_upgrade->description." Silent Upgrade was used to upgrade the instance.";
884 884
 			}
885 885
 		   $new_upgrade->save();
886
-		   set_upgrade_progress('commit','in_progress','upgradeHistory','done');
887
-		   set_upgrade_progress('commit','done','commit','done');
886
+		   set_upgrade_progress('commit', 'in_progress', 'upgradeHistory', 'done');
887
+		   set_upgrade_progress('commit', 'done', 'commit', 'done');
888 888
 		}
889 889
 	  }
890 890
 
891 891
 	//Clean modules from cache
892 892
 	    $cachedir = sugar_cached('smarty');
893
-		if(is_dir($cachedir)){
893
+		if (is_dir($cachedir)) {
894 894
 			$allModFiles = array();
895
-			$allModFiles = findAllFiles($cachedir,$allModFiles);
896
-		   foreach($allModFiles as $file){
895
+			$allModFiles = findAllFiles($cachedir, $allModFiles);
896
+		   foreach ($allModFiles as $file) {
897 897
 		       	//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
898
-		       	if(file_exists($file)){
898
+		       	if (file_exists($file)) {
899 899
 					unlink($file);
900 900
 		       	}
901 901
 		   }
@@ -903,12 +903,12 @@  discard block
 block discarded – undo
903 903
    //delete cache/modules before rebuilding the relations
904 904
    	//Clean modules from cache
905 905
    	    $cachedir = sugar_cached('modules');
906
-		if(is_dir($cachedir)){
906
+		if (is_dir($cachedir)) {
907 907
 			$allModFiles = array();
908
-			$allModFiles = findAllFiles($cachedir,$allModFiles);
909
-		   foreach($allModFiles as $file){
908
+			$allModFiles = findAllFiles($cachedir, $allModFiles);
909
+		   foreach ($allModFiles as $file) {
910 910
 		       	//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
911
-		       	if(file_exists($file)){
911
+		       	if (file_exists($file)) {
912 912
 					unlink($file);
913 913
 		       	}
914 914
 		   }
@@ -916,21 +916,21 @@  discard block
 block discarded – undo
916 916
 
917 917
 		//delete cache/themes
918 918
 		$cachedir = sugar_cached('themes');
919
-		if(is_dir($cachedir)){
919
+		if (is_dir($cachedir)) {
920 920
 			$allModFiles = array();
921
-			$allModFiles = findAllFiles($cachedir,$allModFiles);
922
-		   foreach($allModFiles as $file){
921
+			$allModFiles = findAllFiles($cachedir, $allModFiles);
922
+		   foreach ($allModFiles as $file) {
923 923
 		       	//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
924
-		       	if(file_exists($file)){
924
+		       	if (file_exists($file)) {
925 925
 					unlink($file);
926 926
 		       	}
927 927
 		   }
928 928
 		}
929 929
 	ob_start();
930
-	if(!isset($_REQUEST['silent'])){
930
+	if (!isset($_REQUEST['silent'])) {
931 931
 		$_REQUEST['silent'] = true;
932 932
 	}
933
-	else if(isset($_REQUEST['silent']) && $_REQUEST['silent'] != true){
933
+	else if (isset($_REQUEST['silent']) && $_REQUEST['silent'] != true) {
934 934
 		$_REQUEST['silent'] = true;
935 935
 	}
936 936
 
@@ -942,36 +942,36 @@  discard block
 block discarded – undo
942 942
     //fix_dropdown_list();
943 943
 }
944 944
 
945
-set_upgrade_progress('end','in_progress','end','in_progress');
945
+set_upgrade_progress('end', 'in_progress', 'end', 'in_progress');
946 946
 /////////////////////////Old Logger settings///////////////////////////////////////
947 947
 ///////////////////////////////////////////////////////////////////////////////
948 948
 
949
-if(function_exists('deleteCache')){
950
-	set_upgrade_progress('end','in_progress','deleteCache','in_progress');
949
+if (function_exists('deleteCache')) {
950
+	set_upgrade_progress('end', 'in_progress', 'deleteCache', 'in_progress');
951 951
 	@deleteCache();
952
-	set_upgrade_progress('end','in_progress','deleteCache','done');
952
+	set_upgrade_progress('end', 'in_progress', 'deleteCache', 'done');
953 953
 }
954 954
 
955 955
 ///////////////////////////////////////////////////////////////////////////////
956 956
 ////	HANDLE REMINDERS
957
-if(empty($errors)) {
957
+if (empty($errors)) {
958 958
 	commitHandleReminders($skippedFiles, $path);
959 959
 }
960 960
 
961
-if(file_exists(clean_path(getcwd()).'/original451files')){
961
+if (file_exists(clean_path(getcwd()).'/original451files')) {
962 962
 	rmdir_recursive(clean_path(getcwd()).'/original451files');
963 963
 }
964 964
 
965 965
 require_once('modules/Administration/Administration.php');
966 966
 $admin = new Administration();
967
-$admin->saveSetting('system','adminwizard',1);
967
+$admin->saveSetting('system', 'adminwizard', 1);
968 968
 
969 969
 
970
-if($ce_to_pro_ent)
970
+if ($ce_to_pro_ent)
971 971
 {
972 972
         //check to see if there are any new files that need to be added to systems tab
973 973
         //retrieve old modules list
974
-        logThis('check to see if new modules exist',$path);
974
+        logThis('check to see if new modules exist', $path);
975 975
         $oldModuleList = array();
976 976
         $newModuleList = array();
977 977
         include($argv[3].'/include/modules.php');
@@ -988,13 +988,13 @@  discard block
 block discarded – undo
988 988
         $oldModuleList = $newTB->get_key_array($oldModuleList);
989 989
 
990 990
         //iterate through list and remove commonalities to get new modules
991
-        foreach ($newModuleList as $remove_mod){
992
-            if(in_array($remove_mod, $oldModuleList)){
991
+        foreach ($newModuleList as $remove_mod) {
992
+            if (in_array($remove_mod, $oldModuleList)) {
993 993
                 unset($newModuleList[$remove_mod]);
994 994
             }
995 995
         }
996 996
 
997
-        $must_have_modules= array(
997
+        $must_have_modules = array(
998 998
 			  'Activities'=>'Activities',
999 999
         	  'Calendar'=>'Calendar',
1000 1000
         	  'Reports' => 'Reports',
@@ -1004,42 +1004,42 @@  discard block
 block discarded – undo
1004 1004
 			  'Contracts' => 'Contracts',
1005 1005
 			  'KBDocuments' => 'KBDocuments'
1006 1006
         );
1007
-        $newModuleList = array_merge($newModuleList,$must_have_modules);
1007
+        $newModuleList = array_merge($newModuleList, $must_have_modules);
1008 1008
 
1009 1009
         //new modules list now has left over modules which are new to this install, so lets add them to the system tabs
1010
-        logThis('new modules to add are '.var_export($newModuleList,true),$path);
1010
+        logThis('new modules to add are '.var_export($newModuleList, true), $path);
1011 1011
 
1012 1012
         //grab the existing system tabs
1013 1013
         $tabs = $newTB->get_system_tabs();
1014 1014
 
1015 1015
         //add the new tabs to the array
1016
-        foreach($newModuleList as $nm ){
1016
+        foreach ($newModuleList as $nm) {
1017 1017
           $tabs[$nm] = $nm;
1018 1018
         }
1019 1019
 
1020 1020
         //now assign the modules to system tabs
1021 1021
         $newTB->set_system_tabs($tabs);
1022
-        logThis('module tabs updated',$path);
1022
+        logThis('module tabs updated', $path);
1023 1023
 }
1024 1024
 
1025 1025
 //Also set the tracker settings if  flavor conversion ce->pro or ce->ent
1026
-if(isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])){
1026
+if (isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])) {
1027 1027
     if (version_compare($_SESSION['current_db_version'], $_SESSION['target_db_version'], '='))
1028 1028
     {
1029 1029
 	    $_REQUEST['upgradeWizard'] = true;
1030 1030
 	    ob_start();
1031 1031
 			include('include/Smarty/internals/core.write_file.php');
1032 1032
 		ob_end_clean();
1033
-	 	$db =& DBManagerFactory::getInstance();
1034
-		if($ce_to_pro_ent){
1033
+	 	$db = & DBManagerFactory::getInstance();
1034
+		if ($ce_to_pro_ent) {
1035 1035
 	        //Also set license information
1036 1036
 	        $admin = new Administration();
1037 1037
 			$category = 'license';
1038 1038
 			$value = 0;
1039 1039
 			$admin->saveSetting($category, 'users', $value);
1040
-			$key = array('num_lic_oc','key','expire_date');
1040
+			$key = array('num_lic_oc', 'key', 'expire_date');
1041 1041
 			$value = '';
1042
-			foreach($key as $k){
1042
+			foreach ($key as $k) {
1043 1043
 				$admin->saveSetting($category, $k, $value);
1044 1044
 			}
1045 1045
 		}
@@ -1050,8 +1050,8 @@  discard block
 block discarded – undo
1050 1050
 	ob_end_clean();
1051 1051
 	logThis("**** Potential PHP generated error messages: {$phpErrors}", $path);
1052 1052
 
1053
-	if(count($errors) > 0) {
1054
-		foreach($errors as $error) {
1053
+	if (count($errors) > 0) {
1054
+		foreach ($errors as $error) {
1055 1055
 			logThis("****** SilentUpgrade ERROR: {$error}", $path);
1056 1056
 		}
1057 1057
 		echo "FAILED\n";
@@ -1072,18 +1072,18 @@  discard block
 block discarded – undo
1072 1072
 {
1073 1073
 	$tableDictionaryExtDirs = array('custom/Extension/application/Ext/TableDictionary', 'custom/application/Ext/TableDictionary');
1074 1074
 
1075
-	foreach($tableDictionaryExtDirs as $tableDictionaryExt)
1075
+	foreach ($tableDictionaryExtDirs as $tableDictionaryExt)
1076 1076
 	{
1077 1077
 
1078
-		if(is_dir($tableDictionaryExt) && is_writable($tableDictionaryExt)){
1078
+		if (is_dir($tableDictionaryExt) && is_writable($tableDictionaryExt)) {
1079 1079
 			$dir = dir($tableDictionaryExt);
1080
-			while(($entry = $dir->read()) !== false)
1080
+			while (($entry = $dir->read()) !== false)
1081 1081
 			{
1082
-				$entry = $tableDictionaryExt . '/' . $entry;
1083
-				if(is_file($entry) && preg_match('/\.php$/i', $entry) && is_writeable($entry))
1082
+				$entry = $tableDictionaryExt.'/'.$entry;
1083
+				if (is_file($entry) && preg_match('/\.php$/i', $entry) && is_writeable($entry))
1084 1084
 				{
1085 1085
 
1086
-						if(function_exists('sugar_fopen'))
1086
+						if (function_exists('sugar_fopen'))
1087 1087
 						{
1088 1088
 							$fp = @sugar_fopen($entry, 'r');
1089 1089
 						} else {
@@ -1091,16 +1091,16 @@  discard block
 block discarded – undo
1091 1091
 						}
1092 1092
 
1093 1093
 
1094
-					    if($fp)
1094
+					    if ($fp)
1095 1095
 				        {
1096 1096
 				             $altered = false;
1097 1097
 				             $contents = '';
1098 1098
 
1099
-				             while($line = fgets($fp))
1099
+				             while ($line = fgets($fp))
1100 1100
 						     {
1101
-						    	if(preg_match('/\s*include\s*\(\s*[\'|\"](.*?)[\"|\']\s*\)\s*;/', $line, $match))
1101
+						    	if (preg_match('/\s*include\s*\(\s*[\'|\"](.*?)[\"|\']\s*\)\s*;/', $line, $match))
1102 1102
 						    	{
1103
-						    	   if(!file_exists($match[1]))
1103
+						    	   if (!file_exists($match[1]))
1104 1104
 						    	   {
1105 1105
 						    	      $altered = true;
1106 1106
 						    	   } else {
@@ -1115,16 +1115,16 @@  discard block
 block discarded – undo
1115 1115
 				        }
1116 1116
 
1117 1117
 
1118
-					    if($altered)
1118
+					    if ($altered)
1119 1119
 					    {
1120
-							if(function_exists('sugar_fopen'))
1120
+							if (function_exists('sugar_fopen'))
1121 1121
 							{
1122 1122
 								$fp = @sugar_fopen($entry, 'w');
1123 1123
 							} else {
1124 1124
 								$fp = fopen($entry, 'w');
1125 1125
 							}
1126 1126
 
1127
-							if($fp && fwrite($fp, $contents))
1127
+							if ($fp && fwrite($fp, $contents))
1128 1128
 							{
1129 1129
 								fclose($fp);
1130 1130
 							}
Please login to merge, or discard this patch.
Braces   +12 added lines, -15 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@  discard block
 block discarded – undo
65 65
 			if ($children != "." && $children != "..") {
66 66
 				if (is_dir($thedir . "/" . $children)) {
67 67
 					clearCacheSU($thedir . "/" . $children, $extension);
68
-				}
69
-				elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
68
+				} elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
70 69
 					unlink($thedir . "/" . $children);
71 70
 				}
72 71
 			}
@@ -269,8 +268,7 @@  discard block
 block discarded – undo
269 268
 
270 269
     if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
271 270
         return true;
272
-    }
273
-    else {
271
+    } else {
274 272
         return false;
275 273
     }
276 274
 }
@@ -386,7 +384,9 @@  discard block
 block discarded – undo
386 384
 
387 385
 ///////////////////////////////////////////////////////////////////////////////
388 386
 ////	STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
389
-if(!defined('sugarEntry')) define('sugarEntry', true);
387
+if(!defined('sugarEntry')) {
388
+    define('sugarEntry', true);
389
+}
390 390
 
391 391
 $_SESSION = array();
392 392
 $_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
@@ -500,13 +500,11 @@  discard block
 block discarded – undo
500 500
 	   if(isset($logged_user['id']) && $logged_user['id'] != null){
501 501
 		//do nothing
502 502
 	    $current_user->retrieve($logged_user['id']);
503
-	   }
504
-	   else{
503
+	   } else{
505 504
 	   	echo "FAILURE: Not an admin user in users table. Please provide an admin user\n";
506 505
 		exit(1);
507 506
 	   }
508
-	}
509
-	else {
507
+	} else {
510 508
 		echo "*******************************************************************************\n";
511 509
 		echo "*** ERROR: 4th parameter must be a valid admin user.\n";
512 510
 		echo $usage;
@@ -771,8 +769,9 @@  discard block
 block discarded – undo
771 769
 					include($file);
772 770
 					post_install();
773 771
 				// cn: only run conversion if admin selects "Sugar runs SQL"
774
-				if(!empty($_SESSION['allTables']) && $_SESSION['schema_change'] == 'sugar')
775
-					executeConvertTablesSql($_SESSION['allTables']);
772
+				if(!empty($_SESSION['allTables']) && $_SESSION['schema_change'] == 'sugar') {
773
+									executeConvertTablesSql($_SESSION['allTables']);
774
+				}
776 775
 				//set process to done
777 776
 				$progArray['post_install']='done';
778 777
 				//set_upgrade_progress('commit','in_progress','post_install','done');
@@ -878,8 +877,7 @@  discard block
 block discarded – undo
878 877
 
879 878
 			if($new_upgrade->description == null){
880 879
 				$new_upgrade->description = "Silent Upgrade was used to upgrade the instance";
881
-			}
882
-			else{
880
+			} else{
883 881
 				$new_upgrade->description = $new_upgrade->description." Silent Upgrade was used to upgrade the instance.";
884 882
 			}
885 883
 		   $new_upgrade->save();
@@ -929,8 +927,7 @@  discard block
 block discarded – undo
929 927
 	ob_start();
930 928
 	if(!isset($_REQUEST['silent'])){
931 929
 		$_REQUEST['silent'] = true;
932
-	}
933
-	else if(isset($_REQUEST['silent']) && $_REQUEST['silent'] != true){
930
+	} else if(isset($_REQUEST['silent']) && $_REQUEST['silent'] != true){
934 931
 		$_REQUEST['silent'] = true;
935 932
 	}
936 933
 
Please login to merge, or discard this patch.
modules/UpgradeWizard/uw_emptyFunctions.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,6 +45,6 @@
 block discarded – undo
45 45
 //empty function getJSPath().. there is some dependency in meta upgrade
46 46
 
47 47
 function getJSPath($file=''){
48
-	//nothing here fake function
48
+    //nothing here fake function
49 49
 }
50 50
 ?>
51 51
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 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.
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 //empty function getJSPath().. there is some dependency in meta upgrade
46 46
 
47
-function getJSPath($file=''){
47
+function getJSPath($file = '') {
48 48
 	//nothing here fake function
49 49
 }
50 50
 ?>
51 51
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 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.
Please login to merge, or discard this patch.
modules/UpgradeWizard/systemCheckJson.php 3 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -46,36 +46,36 @@
 block discarded – undo
46 46
  * *******************************************************************************/
47 47
 
48 48
 if(ob_get_level() < 1)
49
-	ob_start();
49
+    ob_start();
50 50
 ob_implicit_flush(1);
51 51
 
52 52
 // load the generated persistence file if found
53 53
 $persistence = array();
54 54
 if(file_exists($persist = sugar_cached('/modules/UpgradeWizard/_persistence.php'))) {
55
-	require_once $persist;
55
+    require_once $persist;
56 56
 }
57 57
 require_once('modules/UpgradeWizard/uw_utils.php');
58 58
 
59 59
 switch($_REQUEST['systemCheckStep']) {
60
-	case 'find_all_files':
61
-		ob_end_flush();
62
-		$persistence['files_to_check'] = getFilesForPermsCheck();
60
+    case 'find_all_files':
61
+        ob_end_flush();
62
+        $persistence['files_to_check'] = getFilesForPermsCheck();
63 63
         break;
64 64
 
65
-	case 'check_found_files':
66
-		if(empty($persistence['files_to_check'])) {
67
-			logThis('*** ERROR: could not find persistent array of files to check');
68
-			echo $mod_strings['ERR_UW_NO_FILES'];
69
-		} else {
70
-			ob_end_flush();
71
-			$persistence = checkFiles($persistence['files_to_check'], true);
72
-		}
73
-	break;
65
+    case 'check_found_files':
66
+        if(empty($persistence['files_to_check'])) {
67
+            logThis('*** ERROR: could not find persistent array of files to check');
68
+            echo $mod_strings['ERR_UW_NO_FILES'];
69
+        } else {
70
+            ob_end_flush();
71
+            $persistence = checkFiles($persistence['files_to_check'], true);
72
+        }
73
+    break;
74 74
 
75
-	case 'check_files_status':
76
-		$ret = ($persistence['filesNotWritable']) ? 'true' : 'false';
77
-		echo $ret;
78
-	break;
75
+    case 'check_files_status':
76
+        $ret = ($persistence['filesNotWritable']) ? 'true' : 'false';
77
+        echo $ret;
78
+    break;
79 79
 }
80 80
 
81 81
 write_array_to_file('persistence', $persistence, $persist);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 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,25 +45,25 @@  discard block
 block discarded – undo
45 45
  * Reserved. Contributor(s): ______________________________________..
46 46
  * *******************************************************************************/
47 47
 
48
-if(ob_get_level() < 1)
48
+if (ob_get_level() < 1)
49 49
 	ob_start();
50 50
 ob_implicit_flush(1);
51 51
 
52 52
 // load the generated persistence file if found
53 53
 $persistence = array();
54
-if(file_exists($persist = sugar_cached('/modules/UpgradeWizard/_persistence.php'))) {
54
+if (file_exists($persist = sugar_cached('/modules/UpgradeWizard/_persistence.php'))) {
55 55
 	require_once $persist;
56 56
 }
57 57
 require_once('modules/UpgradeWizard/uw_utils.php');
58 58
 
59
-switch($_REQUEST['systemCheckStep']) {
59
+switch ($_REQUEST['systemCheckStep']) {
60 60
 	case 'find_all_files':
61 61
 		ob_end_flush();
62 62
 		$persistence['files_to_check'] = getFilesForPermsCheck();
63 63
         break;
64 64
 
65 65
 	case 'check_found_files':
66
-		if(empty($persistence['files_to_check'])) {
66
+		if (empty($persistence['files_to_check'])) {
67 67
 			logThis('*** ERROR: could not find persistent array of files to check');
68 68
 			echo $mod_strings['ERR_UW_NO_FILES'];
69 69
 		} else {
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 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.
@@ -45,8 +47,9 @@  discard block
 block discarded – undo
45 47
  * Reserved. Contributor(s): ______________________________________..
46 48
  * *******************************************************************************/
47 49
 
48
-if(ob_get_level() < 1)
50
+if(ob_get_level() < 1) {
49 51
 	ob_start();
52
+}
50 53
 ob_implicit_flush(1);
51 54
 
52 55
 // load the generated persistence file if found
Please login to merge, or discard this patch.
modules/UpgradeWizard/silentUpgrade_step2.php 3 patches
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -45,76 +45,76 @@  discard block
 block discarded – undo
45 45
 ini_set('memory_limit',-1);
46 46
 ///////////////////////////////////////////////////////////////////////////////
47 47
 ////	UTILITIES THAT MUST BE LOCAL :(
48
- //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
49
- //no found then adds default_permissions to the config file.
50
- function checkConfigForPermissions(){
51
-     if(file_exists(getcwd().'/config.php')){
52
-         require(getcwd().'/config.php');
53
-     }
54
-     global $sugar_config;
55
-     if(!isset($sugar_config['default_permissions'])){
56
-             $sugar_config['default_permissions'] = array (
57
-                     'dir_mode' => 02770,
58
-                     'file_mode' => 0660,
59
-                     'user' => '',
60
-                     'group' => '',
61
-             );
62
-         ksort($sugar_config);
63
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
64
-        	//writing to the file
65
- 		}
66
-     }
48
+    //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
49
+    //no found then adds default_permissions to the config file.
50
+    function checkConfigForPermissions(){
51
+        if(file_exists(getcwd().'/config.php')){
52
+            require(getcwd().'/config.php');
53
+        }
54
+        global $sugar_config;
55
+        if(!isset($sugar_config['default_permissions'])){
56
+                $sugar_config['default_permissions'] = array (
57
+                        'dir_mode' => 02770,
58
+                        'file_mode' => 0660,
59
+                        'user' => '',
60
+                        'group' => '',
61
+                );
62
+            ksort($sugar_config);
63
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
64
+            //writing to the file
65
+            }
66
+        }
67 67
 }
68 68
 
69 69
 function checkLoggerSettings(){
70
-	if(file_exists(getcwd().'/config.php')){
71
-         require(getcwd().'/config.php');
72
-     }
70
+    if(file_exists(getcwd().'/config.php')){
71
+            require(getcwd().'/config.php');
72
+        }
73 73
     global $sugar_config;
74
-	if(!isset($sugar_config['logger'])){
75
-	    $sugar_config['logger'] =array (
76
-			'level'=>'fatal',
77
-		    'file' =>
78
-		     array (
79
-		      'ext' => '.log',
80
-		      'name' => 'sugarcrm',
81
-		      'dateFormat' => '%c',
82
-		      'maxSize' => '10MB',
83
-		      'maxLogs' => 10,
84
-		      'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
85
-		    ),
86
-		  );
87
-		 ksort($sugar_config);
88
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
89
-        	//writing to the file
90
- 		}
91
-	 }
74
+    if(!isset($sugar_config['logger'])){
75
+        $sugar_config['logger'] =array (
76
+            'level'=>'fatal',
77
+            'file' =>
78
+                array (
79
+                'ext' => '.log',
80
+                'name' => 'sugarcrm',
81
+                'dateFormat' => '%c',
82
+                'maxSize' => '10MB',
83
+                'maxLogs' => 10,
84
+                'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
85
+            ),
86
+            );
87
+            ksort($sugar_config);
88
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
89
+            //writing to the file
90
+            }
91
+        }
92 92
 }
93 93
 
94 94
 function checkResourceSettings(){
95
-	if(file_exists(getcwd().'/config.php')){
96
-         require(getcwd().'/config.php');
97
-     }
95
+    if(file_exists(getcwd().'/config.php')){
96
+            require(getcwd().'/config.php');
97
+        }
98 98
     global $sugar_config;
99
-	if(!isset($sugar_config['resource_management'])){
100
-	  $sugar_config['resource_management'] =
101
-		  array (
102
-		    'special_query_limit' => 50000,
103
-		    'special_query_modules' =>
104
-		    array (
105
-		      0 => 'Reports',
106
-		      1 => 'Export',
107
-		      2 => 'Import',
108
-		      3 => 'Administration',
109
-		      4 => 'Sync',
110
-		    ),
111
-		    'default_limit' => 1000,
112
-		  );
113
-		 ksort($sugar_config);
114
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
115
-        	//writing to the file
116
- 		}
117
-	}
99
+    if(!isset($sugar_config['resource_management'])){
100
+        $sugar_config['resource_management'] =
101
+            array (
102
+            'special_query_limit' => 50000,
103
+            'special_query_modules' =>
104
+            array (
105
+                0 => 'Reports',
106
+                1 => 'Export',
107
+                2 => 'Import',
108
+                3 => 'Administration',
109
+                4 => 'Sync',
110
+            ),
111
+            'default_limit' => 1000,
112
+            );
113
+            ksort($sugar_config);
114
+            if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
115
+            //writing to the file
116
+            }
117
+    }
118 118
 }
119 119
 
120 120
 
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 
172 172
 function rebuildRelations($pre_path = '')
173 173
 {
174
-	$_REQUEST['silent'] = true;
175
-	include($pre_path.'modules/Administration/RebuildRelationship.php');
176
-	$_REQUEST['upgradeWizard'] = true;
177
-	include($pre_path.'modules/ACL/install_actions.php');
174
+    $_REQUEST['silent'] = true;
175
+    include($pre_path.'modules/Administration/RebuildRelationship.php');
176
+    $_REQUEST['upgradeWizard'] = true;
177
+    include($pre_path.'modules/ACL/install_actions.php');
178 178
 }
179 179
 
180 180
 //Bug 52872. Dies if the request does not come from CLI.
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 
187 187
 // only run from command line
188 188
 if(isset($_SERVER['HTTP_USER_AGENT'])) {
189
-	fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
190
-	exit(1);
189
+    fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
190
+    exit(1);
191 191
 }
192 192
 //Clean_string cleans out any file  passed in as a parameter
193 193
 $_SERVER['PHP_SELF'] = 'silentUpgrade.php';
@@ -248,60 +248,60 @@  discard block
 block discarded – undo
248 248
 $isDCEInstance = false;
249 249
 $errors = array();
250 250
 
251
-	require('config.php');
252
-	if(isset($argv[3])) {
253
-		if(is_dir($argv[3])) {
254
-			$cwd = $argv[3];
255
-			chdir($cwd);
256
-		}
257
-	}
251
+    require('config.php');
252
+    if(isset($argv[3])) {
253
+        if(is_dir($argv[3])) {
254
+            $cwd = $argv[3];
255
+            chdir($cwd);
256
+        }
257
+    }
258 258
 
259
-	require_once("{$cwd}/sugar_version.php"); // provides $sugar_version & $sugar_flavor
259
+    require_once("{$cwd}/sugar_version.php"); // provides $sugar_version & $sugar_flavor
260 260
 
261
-	global $sugar_config;
262
-	$configOptions = $sugar_config['dbconfig'];
261
+    global $sugar_config;
262
+    $configOptions = $sugar_config['dbconfig'];
263 263
 
264 264
     $GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
265
-	$patchName		= basename($argv[1]);
266
-	$zip_from_dir	= substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip")
267
-	$path			= $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
265
+    $patchName		= basename($argv[1]);
266
+    $zip_from_dir	= substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip")
267
+    $path			= $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
268 268
     $db				= &DBManagerFactory::getInstance();
269
-	$UWstrings		= return_module_language('en_us', 'UpgradeWizard', true);
270
-	$adminStrings	= return_module_language('en_us', 'Administration', true);
269
+    $UWstrings		= return_module_language('en_us', 'UpgradeWizard', true);
270
+    $adminStrings	= return_module_language('en_us', 'Administration', true);
271 271
     $app_list_strings = return_app_list_strings_language('en_us');
272
-	$mod_strings	= array_merge($adminStrings, $UWstrings);
273
-	$subdirs		= array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
274
-	global $unzip_dir;
272
+    $mod_strings	= array_merge($adminStrings, $UWstrings);
273
+    $subdirs		= array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
274
+    global $unzip_dir;
275 275
     $license_accepted = false;
276 276
     if(isset($argv[5]) && (strtolower($argv[5])=='yes' || strtolower($argv[5])=='y')){
277
-    	$license_accepted = true;
278
-	 }
279
-	//////////////////////////////////////////////////////////////////////////////
280
-	//Adding admin user to the silent upgrade
281
-
282
-	$current_user = new User();
283
-	if(isset($argv[4])) {
284
-	   //if being used for internal upgrades avoid admin user verification
285
-	   $user_name = $argv[4];
286
-	   $q = "select id from users where user_name = '" . $user_name . "' and is_admin=1";
287
-	   $result = $GLOBALS['db']->query($q, false);
288
-	   $logged_user = $GLOBALS['db']->fetchByAssoc($result);
289
-	   if(isset($logged_user['id']) && $logged_user['id'] != null){
290
-		//do nothing
291
-	    $current_user->retrieve($logged_user['id']);
292
-	   }
293
-	   else{
294
-	   	echo "Not an admin user in users table. Please provide an admin user\n";
295
-		exit(1);
296
-	   }
297
-	}
298
-	else {
299
-		echo "*******************************************************************************\n";
300
-		echo "*** ERROR: 4th parameter must be a valid admin user.\n";
301
-		echo $usage;
302
-		echo "FAILURE\n";
303
-		exit(1);
304
-	}
277
+        $license_accepted = true;
278
+        }
279
+    //////////////////////////////////////////////////////////////////////////////
280
+    //Adding admin user to the silent upgrade
281
+
282
+    $current_user = new User();
283
+    if(isset($argv[4])) {
284
+        //if being used for internal upgrades avoid admin user verification
285
+        $user_name = $argv[4];
286
+        $q = "select id from users where user_name = '" . $user_name . "' and is_admin=1";
287
+        $result = $GLOBALS['db']->query($q, false);
288
+        $logged_user = $GLOBALS['db']->fetchByAssoc($result);
289
+        if(isset($logged_user['id']) && $logged_user['id'] != null){
290
+        //do nothing
291
+        $current_user->retrieve($logged_user['id']);
292
+        }
293
+        else{
294
+            echo "Not an admin user in users table. Please provide an admin user\n";
295
+        exit(1);
296
+        }
297
+    }
298
+    else {
299
+        echo "*******************************************************************************\n";
300
+        echo "*** ERROR: 4th parameter must be a valid admin user.\n";
301
+        echo $usage;
302
+        echo "FAILURE\n";
303
+        exit(1);
304
+    }
305 305
 
306 306
 /////retrieve admin user
307 307
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
 mkdir_recursive($unzip_dir);
317 317
 if(!is_dir($unzip_dir)) {
318
-	fwrite(STDERR,"\n{$unzip_dir} is not an available directory\nFAILURE\n");
318
+    fwrite(STDERR,"\n{$unzip_dir} is not an available directory\nFAILURE\n");
319 319
     exit(1);
320 320
 }
321 321
 unzip($argv[1], $unzip_dir);
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 
327 327
 
328 328
 if(function_exists('set_upgrade_vars')){
329
-	set_upgrade_vars();
329
+    set_upgrade_vars();
330 330
 }
331 331
 
332 332
 ///////////////////////////////////////////////////////////////////////////////
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
 logThis('Upgrading user preferences start .', $path);
352 352
 if(function_exists('upgradeUserPreferences')){
353
-   upgradeUserPreferences();
353
+    upgradeUserPreferences();
354 354
 }
355 355
 logThis('Upgrading user preferences finish .', $path);
356 356
 
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 //Add the cache cleaning here.
375 375
 if(function_exists('deleteCache'))
376 376
 {
377
-	logThis('Call deleteCache', $path);
378
-	@deleteCache();
377
+    logThis('Call deleteCache', $path);
378
+    @deleteCache();
379 379
 }
380 380
 /*
381 381
 // creating full text search logic hooks
@@ -418,50 +418,50 @@  discard block
 block discarded – undo
418 418
 
419 419
 $repairedTables = array();
420 420
 foreach ($beanFiles as $bean => $file) {
421
-	if(file_exists($file)){
422
-		unset($GLOBALS['dictionary'][$bean]);
423
-		require_once($file);
424
-		$focus = new $bean ();
425
-		if(empty($focus->table_name) || isset($repairedTables[$focus->table_name])) {
426
-		   continue;
427
-		}
428
-
429
-		if (($focus instanceOf SugarBean)) {
430
-			if(!isset($repairedTables[$focus->table_name]))
431
-			{
432
-				$sql = $GLOBALS['db']->repairTable($focus, true);
421
+    if(file_exists($file)){
422
+        unset($GLOBALS['dictionary'][$bean]);
423
+        require_once($file);
424
+        $focus = new $bean ();
425
+        if(empty($focus->table_name) || isset($repairedTables[$focus->table_name])) {
426
+            continue;
427
+        }
428
+
429
+        if (($focus instanceOf SugarBean)) {
430
+            if(!isset($repairedTables[$focus->table_name]))
431
+            {
432
+                $sql = $GLOBALS['db']->repairTable($focus, true);
433 433
                 if(trim($sql) != '')
434 434
                 {
435
-				    logThis('Running sql:' . $sql, $path);
435
+                    logThis('Running sql:' . $sql, $path);
436 436
                 }
437
-				$repairedTables[$focus->table_name] = true;
438
-			}
437
+                $repairedTables[$focus->table_name] = true;
438
+            }
439 439
 
440
-			//Check to see if we need to create the audit table
441
-		    if($focus->is_AuditEnabled() && !$focus->db->tableExists($focus->get_audit_table_name())){
442
-               logThis('Creating audit table:' . $focus->get_audit_table_name(), $path);
443
-		       $focus->create_audit_table();
440
+            //Check to see if we need to create the audit table
441
+            if($focus->is_AuditEnabled() && !$focus->db->tableExists($focus->get_audit_table_name())){
442
+                logThis('Creating audit table:' . $focus->get_audit_table_name(), $path);
443
+                $focus->create_audit_table();
444 444
             }
445
-		}
446
-	}
445
+        }
446
+    }
447 447
 }
448 448
 
449 449
 unset ($dictionary);
450 450
 include ("{$argv[3]}/modules/TableDictionary.php");
451 451
 foreach ($dictionary as $meta) {
452
-	$tablename = $meta['table'];
452
+    $tablename = $meta['table'];
453 453
 
454
-	if(isset($repairedTables[$tablename])) {
455
-	   continue;
456
-	}
454
+    if(isset($repairedTables[$tablename])) {
455
+        continue;
456
+    }
457 457
 
458
-	$fielddefs = $meta['fields'];
459
-	$indices = $meta['indices'];
460
-	$sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
461
-	if(!empty($sql)) {
462
-	    logThis($sql, $path);
463
-	    $repairedTables[$tablename] = true;
464
-	}
458
+    $fielddefs = $meta['fields'];
459
+    $indices = $meta['indices'];
460
+    $sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
461
+    if(!empty($sql)) {
462
+        logThis($sql, $path);
463
+        $repairedTables[$tablename] = true;
464
+    }
465 465
 
466 466
 }
467 467
 
@@ -482,18 +482,18 @@  discard block
 block discarded – undo
482 482
 
483 483
 
484 484
 if($ce_to_pro_ent) {
485
-	//add the global team if it does not exist
486
-	$globalteam = new Team();
487
-	$globalteam->retrieve('1');
488
-	require_once($unzip_dir.'/'.$zip_from_dir.'/modules/Administration/language/en_us.lang.php');
489
-	if(isset($globalteam->name)){
490
-		echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>';
491
-		logThis(" Finish Building Global Team", $path);
492
-	}else{
493
-		$globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team);
494
-	}
495
-
496
-	logThis(" Start Building private teams", $path);
485
+    //add the global team if it does not exist
486
+    $globalteam = new Team();
487
+    $globalteam->retrieve('1');
488
+    require_once($unzip_dir.'/'.$zip_from_dir.'/modules/Administration/language/en_us.lang.php');
489
+    if(isset($globalteam->name)){
490
+        echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>';
491
+        logThis(" Finish Building Global Team", $path);
492
+    }else{
493
+        $globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team);
494
+    }
495
+
496
+    logThis(" Start Building private teams", $path);
497 497
 
498 498
     upgradeModulesForTeam();
499 499
     logThis(" Finish Building private teams", $path);
@@ -502,12 +502,12 @@  discard block
 block discarded – undo
502 502
     upgradeModulesForTeamsets();
503 503
     logThis(" Finish Building the team_set and team_sets_teams", $path);
504 504
 
505
-	logThis(" Start modules/Administration/upgradeTeams.php", $path);
505
+    logThis(" Start modules/Administration/upgradeTeams.php", $path);
506 506
         include('modules/Administration/upgradeTeams.php');
507 507
         logThis(" Finish modules/Administration/upgradeTeams.php", $path);
508 508
 
509 509
     if(check_FTS()){
510
-    	$GLOBALS['db']->full_text_indexing_setup();
510
+        $GLOBALS['db']->full_text_indexing_setup();
511 511
     }
512 512
 }
513 513
 
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 //Unlink files that have been removed
526 526
 if(function_exists('unlinkUpgradeFiles'))
527 527
 {
528
-	unlinkUpgradeFiles($sugar_version);
528
+    unlinkUpgradeFiles($sugar_version);
529 529
 }
530 530
 
531 531
 if(function_exists('rebuildSprites') && function_exists('imagecreatetruecolor'))
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
 ///////////////////////////////////////////////////////////////////////////////
543 543
 ////	TAKE OUT TRASH
544 544
 if(empty($errors)) {
545
-	set_upgrade_progress('end','in_progress','unlinkingfiles','in_progress');
546
-	logThis('Taking out the trash, unlinking temp files.', $path);
547
-	unlinkUWTempFiles();
548
-	removeSilentUpgradeVarsCache();
549
-	logThis('Taking out the trash, done.', $path);
545
+    set_upgrade_progress('end','in_progress','unlinkingfiles','in_progress');
546
+    logThis('Taking out the trash, unlinking temp files.', $path);
547
+    unlinkUWTempFiles();
548
+    removeSilentUpgradeVarsCache();
549
+    logThis('Taking out the trash, done.', $path);
550 550
 }
551 551
 
552 552
 ///////////////////////////////////////////////////////////////////////////////
@@ -557,20 +557,20 @@  discard block
 block discarded – undo
557 557
 logThis("**** Potential PHP generated error messages: {$phpErrors}", $path);
558 558
 
559 559
 if(count($errors) > 0) {
560
-	foreach($errors as $error) {
561
-		logThis("****** SilentUpgrade ERROR: {$error}", $path);
562
-	}
563
-	echo "FAILED\n";
560
+    foreach($errors as $error) {
561
+        logThis("****** SilentUpgrade ERROR: {$error}", $path);
562
+    }
563
+    echo "FAILED\n";
564 564
 } else {
565
-	logThis("***** SilentUpgrade completed successfully.", $path);
566
-	echo "********************************************************************\n";
567
-	echo "*************************** SUCCESS*********************************\n";
568
-	echo "********************************************************************\n";
569
-	echo "******** If your pre-upgrade Leads data is not showing  ************\n";
570
-	echo "******** Or you see errors in detailview subpanels  ****************\n";
571
-	echo "************* In order to resolve them  ****************************\n";
572
-	echo "******** Log into application as Administrator  ********************\n";
573
-	echo "******** Go to Admin panel  ****************************************\n";
574
-	echo "******** Run Repair -> Rebuild Relationships  **********************\n";
575
-	echo "********************************************************************\n";
565
+    logThis("***** SilentUpgrade completed successfully.", $path);
566
+    echo "********************************************************************\n";
567
+    echo "*************************** SUCCESS*********************************\n";
568
+    echo "********************************************************************\n";
569
+    echo "******** If your pre-upgrade Leads data is not showing  ************\n";
570
+    echo "******** Or you see errors in detailview subpanels  ****************\n";
571
+    echo "************* In order to resolve them  ****************************\n";
572
+    echo "******** Log into application as Administrator  ********************\n";
573
+    echo "******** Go to Admin panel  ****************************************\n";
574
+    echo "******** Run Repair -> Rebuild Relationships  **********************\n";
575
+    echo "********************************************************************\n";
576 576
 }
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -42,40 +42,40 @@  discard block
 block discarded – undo
42 42
 //// php.exe -f silentUpgrade.php [Path to Upgrade Package zip] [Path to Log file] [Path to Instance]
43 43
 //// See below the Usage for more details.
44 44
 /////////////////////////////////////////////////////////////////////////////////////////
45
-ini_set('memory_limit',-1);
45
+ini_set('memory_limit', -1);
46 46
 ///////////////////////////////////////////////////////////////////////////////
47 47
 ////	UTILITIES THAT MUST BE LOCAL :(
48 48
  //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
49 49
  //no found then adds default_permissions to the config file.
50
- function checkConfigForPermissions(){
51
-     if(file_exists(getcwd().'/config.php')){
50
+ function checkConfigForPermissions() {
51
+     if (file_exists(getcwd().'/config.php')) {
52 52
          require(getcwd().'/config.php');
53 53
      }
54 54
      global $sugar_config;
55
-     if(!isset($sugar_config['default_permissions'])){
56
-             $sugar_config['default_permissions'] = array (
55
+     if (!isset($sugar_config['default_permissions'])) {
56
+             $sugar_config['default_permissions'] = array(
57 57
                      'dir_mode' => 02770,
58 58
                      'file_mode' => 0660,
59 59
                      'user' => '',
60 60
                      'group' => '',
61 61
              );
62 62
          ksort($sugar_config);
63
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
63
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
64 64
         	//writing to the file
65 65
  		}
66 66
      }
67 67
 }
68 68
 
69
-function checkLoggerSettings(){
70
-	if(file_exists(getcwd().'/config.php')){
69
+function checkLoggerSettings() {
70
+	if (file_exists(getcwd().'/config.php')) {
71 71
          require(getcwd().'/config.php');
72 72
      }
73 73
     global $sugar_config;
74
-	if(!isset($sugar_config['logger'])){
75
-	    $sugar_config['logger'] =array (
74
+	if (!isset($sugar_config['logger'])) {
75
+	    $sugar_config['logger'] = array(
76 76
 			'level'=>'fatal',
77 77
 		    'file' =>
78
-		     array (
78
+		     array(
79 79
 		      'ext' => '.log',
80 80
 		      'name' => 'sugarcrm',
81 81
 		      'dateFormat' => '%c',
@@ -85,23 +85,23 @@  discard block
 block discarded – undo
85 85
 		    ),
86 86
 		  );
87 87
 		 ksort($sugar_config);
88
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
88
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
89 89
         	//writing to the file
90 90
  		}
91 91
 	 }
92 92
 }
93 93
 
94
-function checkResourceSettings(){
95
-	if(file_exists(getcwd().'/config.php')){
94
+function checkResourceSettings() {
95
+	if (file_exists(getcwd().'/config.php')) {
96 96
          require(getcwd().'/config.php');
97 97
      }
98 98
     global $sugar_config;
99
-	if(!isset($sugar_config['resource_management'])){
99
+	if (!isset($sugar_config['resource_management'])) {
100 100
 	  $sugar_config['resource_management'] =
101
-		  array (
101
+		  array(
102 102
 		    'special_query_limit' => 50000,
103 103
 		    'special_query_modules' =>
104
-		    array (
104
+		    array(
105 105
 		      0 => 'Reports',
106 106
 		      1 => 'Export',
107 107
 		      2 => 'Import',
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
 		    'default_limit' => 1000,
112 112
 		  );
113 113
 		 ksort($sugar_config);
114
-         if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
114
+         if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) {
115 115
         	//writing to the file
116 116
  		}
117 117
 	}
118 118
 }
119 119
 
120 120
 
121
-function verifyArguments($argv,$usage_regular){
121
+function verifyArguments($argv, $usage_regular) {
122 122
     $upgradeType = '';
123 123
     $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
124
-    if(isset($argv[3])) {
125
-        if(is_dir($argv[3])) {
124
+    if (isset($argv[3])) {
125
+        if (is_dir($argv[3])) {
126 126
             $cwd = $argv[3];
127 127
             chdir($cwd);
128 128
         } else {
@@ -133,18 +133,18 @@  discard block
 block discarded – undo
133 133
     }
134 134
 
135 135
     //check if this is an instance
136
-    if(is_file("{$cwd}/include/entryPoint.php")) {
136
+    if (is_file("{$cwd}/include/entryPoint.php")) {
137 137
         //this should be a regular sugar install
138 138
         $upgradeType = constant('SUGARCRM_INSTALL');
139 139
         //check if this is a valid zip file
140
-        if(!is_file($argv[1])) { // valid zip?
140
+        if (!is_file($argv[1])) { // valid zip?
141 141
             echo "*******************************************************************************\n";
142 142
             echo "*** ERROR: First argument must be a full path to the patch file. Got [ {$argv[1]} ].\n";
143 143
             echo $usage_regular;
144 144
             echo "FAILURE\n";
145 145
             exit(1);
146 146
         }
147
-        if(count($argv) < 5) {
147
+        if (count($argv) < 5) {
148 148
             echo "*******************************************************************************\n";
149 149
             echo "*** ERROR: Missing required parameters.  Received ".count($argv)." argument(s), require 5.\n";
150 150
             echo $usage_regular;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         exit(1);
160 160
     }
161 161
 
162
-    if(isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')){
162
+    if (isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')) {
163 163
         require_once($argv[7].'SugarTemplateUtilties.php');
164 164
     }
165 165
 
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 //End of #52872
186 186
 
187 187
 // only run from command line
188
-if(isset($_SERVER['HTTP_USER_AGENT'])) {
189
-	fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
188
+if (isset($_SERVER['HTTP_USER_AGENT'])) {
189
+	fwrite(STDERR, 'This utility may only be run from the command line or command prompt.');
190 190
 	exit(1);
191 191
 }
192 192
 //Clean_string cleans out any file  passed in as a parameter
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
 ///////////////////////////////////////////////////////////////////////////////
197 197
 ////	USAGE
198
-$usage_regular =<<<eoq2
198
+$usage_regular = <<<eoq2
199 199
 Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance] [admin-user]
200 200
 
201 201
 On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 
218 218
 ///////////////////////////////////////////////////////////////////////////////
219 219
 ////	STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
220
-if(!defined('sugarEntry')) define('sugarEntry', true);
220
+if (!defined('sugarEntry')) define('sugarEntry', true);
221 221
 
222 222
 $_SESSION = array();
223 223
 $_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 global $cwd;
235 235
 $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
236 236
 
237
-$upgradeType = verifyArguments($argv,$usage_regular);
237
+$upgradeType = verifyArguments($argv, $usage_regular);
238 238
 
239
-$path			= $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
240
-$subdirs		= array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
239
+$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
240
+$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
241 241
 
242 242
 require_once('include/entryPoint.php');
243 243
 require_once('modules/UpgradeWizard/uw_utils.php');
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 $errors = array();
250 250
 
251 251
 	require('config.php');
252
-	if(isset($argv[3])) {
253
-		if(is_dir($argv[3])) {
252
+	if (isset($argv[3])) {
253
+		if (is_dir($argv[3])) {
254 254
 			$cwd = $argv[3];
255 255
 			chdir($cwd);
256 256
 		}
@@ -261,36 +261,36 @@  discard block
 block discarded – undo
261 261
 	global $sugar_config;
262 262
 	$configOptions = $sugar_config['dbconfig'];
263 263
 
264
-    $GLOBALS['log']	= LoggerManager::getLogger('SugarCRM');
265
-	$patchName		= basename($argv[1]);
266
-	$zip_from_dir	= substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip")
267
-	$path			= $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
268
-    $db				= &DBManagerFactory::getInstance();
269
-	$UWstrings		= return_module_language('en_us', 'UpgradeWizard', true);
270
-	$adminStrings	= return_module_language('en_us', 'Administration', true);
264
+    $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
265
+	$patchName = basename($argv[1]);
266
+	$zip_from_dir = substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip")
267
+	$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
268
+    $db = &DBManagerFactory::getInstance();
269
+	$UWstrings = return_module_language('en_us', 'UpgradeWizard', true);
270
+	$adminStrings = return_module_language('en_us', 'Administration', true);
271 271
     $app_list_strings = return_app_list_strings_language('en_us');
272
-	$mod_strings	= array_merge($adminStrings, $UWstrings);
273
-	$subdirs		= array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
272
+	$mod_strings = array_merge($adminStrings, $UWstrings);
273
+	$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
274 274
 	global $unzip_dir;
275 275
     $license_accepted = false;
276
-    if(isset($argv[5]) && (strtolower($argv[5])=='yes' || strtolower($argv[5])=='y')){
276
+    if (isset($argv[5]) && (strtolower($argv[5]) == 'yes' || strtolower($argv[5]) == 'y')) {
277 277
     	$license_accepted = true;
278 278
 	 }
279 279
 	//////////////////////////////////////////////////////////////////////////////
280 280
 	//Adding admin user to the silent upgrade
281 281
 
282 282
 	$current_user = new User();
283
-	if(isset($argv[4])) {
283
+	if (isset($argv[4])) {
284 284
 	   //if being used for internal upgrades avoid admin user verification
285 285
 	   $user_name = $argv[4];
286
-	   $q = "select id from users where user_name = '" . $user_name . "' and is_admin=1";
286
+	   $q = "select id from users where user_name = '".$user_name."' and is_admin=1";
287 287
 	   $result = $GLOBALS['db']->query($q, false);
288 288
 	   $logged_user = $GLOBALS['db']->fetchByAssoc($result);
289
-	   if(isset($logged_user['id']) && $logged_user['id'] != null){
289
+	   if (isset($logged_user['id']) && $logged_user['id'] != null) {
290 290
 		//do nothing
291 291
 	    $current_user->retrieve($logged_user['id']);
292 292
 	   }
293
-	   else{
293
+	   else {
294 294
 	   	echo "Not an admin user in users table. Please provide an admin user\n";
295 295
 		exit(1);
296 296
 	   }
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 $_SESSION['zip_from_dir'] = $zip_from_dir;
315 315
 
316 316
 mkdir_recursive($unzip_dir);
317
-if(!is_dir($unzip_dir)) {
318
-	fwrite(STDERR,"\n{$unzip_dir} is not an available directory\nFAILURE\n");
317
+if (!is_dir($unzip_dir)) {
318
+	fwrite(STDERR, "\n{$unzip_dir} is not an available directory\nFAILURE\n");
319 319
     exit(1);
320 320
 }
321 321
 unzip($argv[1], $unzip_dir);
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 ///////////////////////////////////////////////////////////////////////////////
326 326
 
327 327
 
328
-if(function_exists('set_upgrade_vars')){
328
+if (function_exists('set_upgrade_vars')) {
329 329
 	set_upgrade_vars();
330 330
 }
331 331
 
@@ -349,18 +349,18 @@  discard block
 block discarded – undo
349 349
 upgrade_custom_relationships();
350 350
 
351 351
 logThis('Upgrading user preferences start .', $path);
352
-if(function_exists('upgradeUserPreferences')){
352
+if (function_exists('upgradeUserPreferences')) {
353 353
    upgradeUserPreferences();
354 354
 }
355 355
 logThis('Upgrading user preferences finish .', $path);
356 356
 
357 357
 // clear out the theme cache
358
-if(is_dir($GLOBALS['sugar_config']['cache_dir'].'themes')){
358
+if (is_dir($GLOBALS['sugar_config']['cache_dir'].'themes')) {
359 359
     $allModFiles = array();
360
-    $allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'themes',$allModFiles);
361
-    foreach($allModFiles as $file){
360
+    $allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'themes', $allModFiles);
361
+    foreach ($allModFiles as $file) {
362 362
         //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
363
-        if(file_exists($file)){
363
+        if (file_exists($file)) {
364 364
             unlink($file);
365 365
         }
366 366
     }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 require_once('jssource/minify.php');
373 373
 
374 374
 //Add the cache cleaning here.
375
-if(function_exists('deleteCache'))
375
+if (function_exists('deleteCache'))
376 376
 {
377 377
 	logThis('Call deleteCache', $path);
378 378
 	@deleteCache();
@@ -411,35 +411,35 @@  discard block
 block discarded – undo
411 411
 $rac->clearVardefs();
412 412
 $rac->rebuildExtensions();
413 413
 //bug: 44431 - defensive check to ensure the method exists since upgrades to 6.2.0 may not have this method define yet.
414
-if(method_exists($rac, 'clearExternalAPICache'))
414
+if (method_exists($rac, 'clearExternalAPICache'))
415 415
 {
416 416
     $rac->clearExternalAPICache();
417 417
 }
418 418
 
419 419
 $repairedTables = array();
420 420
 foreach ($beanFiles as $bean => $file) {
421
-	if(file_exists($file)){
421
+	if (file_exists($file)) {
422 422
 		unset($GLOBALS['dictionary'][$bean]);
423 423
 		require_once($file);
424
-		$focus = new $bean ();
425
-		if(empty($focus->table_name) || isset($repairedTables[$focus->table_name])) {
424
+		$focus = new $bean();
425
+		if (empty($focus->table_name) || isset($repairedTables[$focus->table_name])) {
426 426
 		   continue;
427 427
 		}
428 428
 
429 429
 		if (($focus instanceOf SugarBean)) {
430
-			if(!isset($repairedTables[$focus->table_name]))
430
+			if (!isset($repairedTables[$focus->table_name]))
431 431
 			{
432 432
 				$sql = $GLOBALS['db']->repairTable($focus, true);
433
-                if(trim($sql) != '')
433
+                if (trim($sql) != '')
434 434
                 {
435
-				    logThis('Running sql:' . $sql, $path);
435
+				    logThis('Running sql:'.$sql, $path);
436 436
                 }
437 437
 				$repairedTables[$focus->table_name] = true;
438 438
 			}
439 439
 
440 440
 			//Check to see if we need to create the audit table
441
-		    if($focus->is_AuditEnabled() && !$focus->db->tableExists($focus->get_audit_table_name())){
442
-               logThis('Creating audit table:' . $focus->get_audit_table_name(), $path);
441
+		    if ($focus->is_AuditEnabled() && !$focus->db->tableExists($focus->get_audit_table_name())) {
442
+               logThis('Creating audit table:'.$focus->get_audit_table_name(), $path);
443 443
 		       $focus->create_audit_table();
444 444
             }
445 445
 		}
@@ -451,14 +451,14 @@  discard block
 block discarded – undo
451 451
 foreach ($dictionary as $meta) {
452 452
 	$tablename = $meta['table'];
453 453
 
454
-	if(isset($repairedTables[$tablename])) {
454
+	if (isset($repairedTables[$tablename])) {
455 455
 	   continue;
456 456
 	}
457 457
 
458 458
 	$fielddefs = $meta['fields'];
459 459
 	$indices = $meta['indices'];
460 460
 	$sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
461
-	if(!empty($sql)) {
461
+	if (!empty($sql)) {
462 462
 	    logThis($sql, $path);
463 463
 	    $repairedTables[$tablename] = true;
464 464
 	}
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 logThis('End rebuild relationships.', $path);
473 473
 
474 474
 include("$unzip_dir/manifest.php");
475
-$ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt'  || $manifest['name'] == 'SugarCE to SugarCorp' || $manifest['name'] == 'SugarCE to SugarUlt');
475
+$ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt' || $manifest['name'] == 'SugarCE to SugarCorp' || $manifest['name'] == 'SugarCE to SugarUlt');
476 476
 $sugar_version = getSilentUpgradeVar('origVersion');
477 477
 if (!$sugar_version)
478 478
 {
@@ -481,15 +481,15 @@  discard block
 block discarded – undo
481 481
 }
482 482
 
483 483
 
484
-if($ce_to_pro_ent) {
484
+if ($ce_to_pro_ent) {
485 485
 	//add the global team if it does not exist
486 486
 	$globalteam = new Team();
487 487
 	$globalteam->retrieve('1');
488 488
 	require_once($unzip_dir.'/'.$zip_from_dir.'/modules/Administration/language/en_us.lang.php');
489
-	if(isset($globalteam->name)){
489
+	if (isset($globalteam->name)) {
490 490
 		echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>';
491 491
 		logThis(" Finish Building Global Team", $path);
492
-	}else{
492
+	} else {
493 493
 		$globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team);
494 494
 	}
495 495
 
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
         include('modules/Administration/upgradeTeams.php');
507 507
         logThis(" Finish modules/Administration/upgradeTeams.php", $path);
508 508
 
509
-    if(check_FTS()){
509
+    if (check_FTS()) {
510 510
     	$GLOBALS['db']->full_text_indexing_setup();
511 511
     }
512 512
 }
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
 
524 524
 
525 525
 //Unlink files that have been removed
526
-if(function_exists('unlinkUpgradeFiles'))
526
+if (function_exists('unlinkUpgradeFiles'))
527 527
 {
528 528
 	unlinkUpgradeFiles($sugar_version);
529 529
 }
530 530
 
531
-if(function_exists('rebuildSprites') && function_exists('imagecreatetruecolor'))
531
+if (function_exists('rebuildSprites') && function_exists('imagecreatetruecolor'))
532 532
 {
533 533
     rebuildSprites(true);
534 534
 }
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
 
542 542
 ///////////////////////////////////////////////////////////////////////////////
543 543
 ////	TAKE OUT TRASH
544
-if(empty($errors)) {
545
-	set_upgrade_progress('end','in_progress','unlinkingfiles','in_progress');
544
+if (empty($errors)) {
545
+	set_upgrade_progress('end', 'in_progress', 'unlinkingfiles', 'in_progress');
546 546
 	logThis('Taking out the trash, unlinking temp files.', $path);
547 547
 	unlinkUWTempFiles();
548 548
 	removeSilentUpgradeVarsCache();
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
 ob_end_clean();
557 557
 logThis("**** Potential PHP generated error messages: {$phpErrors}", $path);
558 558
 
559
-if(count($errors) > 0) {
560
-	foreach($errors as $error) {
559
+if (count($errors) > 0) {
560
+	foreach ($errors as $error) {
561 561
 		logThis("****** SilentUpgrade ERROR: {$error}", $path);
562 562
 	}
563 563
 	echo "FAILED\n";
Please login to merge, or discard this patch.
Braces   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -151,8 +151,7 @@  discard block
 block discarded – undo
151 151
             echo "FAILURE\n";
152 152
             exit(1);
153 153
         }
154
-    }
155
-    else {
154
+    } else {
156 155
         //this should be a regular sugar install
157 156
         echo "*******************************************************************************\n";
158 157
         echo "*** ERROR: Tried to execute in a non-SugarCRM root directory.\n";
@@ -217,7 +216,9 @@  discard block
 block discarded – undo
217 216
 
218 217
 ///////////////////////////////////////////////////////////////////////////////
219 218
 ////	STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
220
-if(!defined('sugarEntry')) define('sugarEntry', true);
219
+if(!defined('sugarEntry')) {
220
+    define('sugarEntry', true);
221
+}
221 222
 
222 223
 $_SESSION = array();
223 224
 $_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
@@ -289,13 +290,11 @@  discard block
 block discarded – undo
289 290
 	   if(isset($logged_user['id']) && $logged_user['id'] != null){
290 291
 		//do nothing
291 292
 	    $current_user->retrieve($logged_user['id']);
292
-	   }
293
-	   else{
293
+	   } else{
294 294
 	   	echo "Not an admin user in users table. Please provide an admin user\n";
295 295
 		exit(1);
296 296
 	   }
297
-	}
298
-	else {
297
+	} else {
299 298
 		echo "*******************************************************************************\n";
300 299
 		echo "*** ERROR: 4th parameter must be a valid admin user.\n";
301 300
 		echo $usage;
@@ -489,7 +488,7 @@  discard block
 block discarded – undo
489 488
 	if(isset($globalteam->name)){
490 489
 		echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>';
491 490
 		logThis(" Finish Building Global Team", $path);
492
-	}else{
491
+	} else{
493 492
 		$globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team);
494 493
 	}
495 494
 
Please login to merge, or discard this patch.
modules/UpgradeWizard/preflightJson.php 3 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -46,40 +46,40 @@
 block discarded – undo
46 46
  * *******************************************************************************/
47 47
 
48 48
 if(ob_get_level() < 1)
49
-	ob_start();
49
+    ob_start();
50 50
 ob_implicit_flush(1);
51 51
 
52 52
 // load the generated persistence file if found
53 53
 $persistence = array();
54 54
 if(file_exists($persist = sugar_cached('/modules/UpgradeWizard/_persistence.php'))) {
55
-	require_once $persist;
55
+    require_once $persist;
56 56
 }
57 57
 require_once('modules/UpgradeWizard/uw_utils.php');
58 58
 require_once('include/utils/zip_utils.php');
59 59
 
60 60
 switch($_REQUEST['preflightStep']) {
61
-	case 'find_upgrade_files':
62
-		logThis('preflightJson finding upgrade files');
63
-		ob_end_flush();
64
-		$persistence['upgrade_files'] = preflightCheckJsonFindUpgradeFiles();
65
-	break;
61
+    case 'find_upgrade_files':
62
+        logThis('preflightJson finding upgrade files');
63
+        ob_end_flush();
64
+        $persistence['upgrade_files'] = preflightCheckJsonFindUpgradeFiles();
65
+    break;
66 66
 
67
-	case 'diff_upgrade_files':
68
-		logThis('preflightJson diffing upgrade files');
69
-		ob_end_flush();
70
-		$persistence = preflightCheckJsonDiffFiles();
71
-	break;
67
+    case 'diff_upgrade_files':
68
+        logThis('preflightJson diffing upgrade files');
69
+        ob_end_flush();
70
+        $persistence = preflightCheckJsonDiffFiles();
71
+    break;
72 72
 
73
-	case 'get_diff_results':
74
-		logThis('preflightJson getting diff results for display');
75
-		ob_end_flush();
76
-		$persistence = preflightCheckJsonGetDiff();
77
-	break;
73
+    case 'get_diff_results':
74
+        logThis('preflightJson getting diff results for display');
75
+        ob_end_flush();
76
+        $persistence = preflightCheckJsonGetDiff();
77
+    break;
78 78
 
79
-	case 'get_diff_errors':
80
-		logThis('preflightJson getting diff errors (if any)');
81
-		preflightCheckJsonGetDiffErrors();
82
-	break;
79
+    case 'get_diff_errors':
80
+        logThis('preflightJson getting diff errors (if any)');
81
+        preflightCheckJsonGetDiffErrors();
82
+    break;
83 83
 }
84 84
 
85 85
 write_array_to_file('persistence', $persistence, $persist);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 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,19 +45,19 @@  discard block
 block discarded – undo
45 45
  * Reserved. Contributor(s): ______________________________________..
46 46
  * *******************************************************************************/
47 47
 
48
-if(ob_get_level() < 1)
48
+if (ob_get_level() < 1)
49 49
 	ob_start();
50 50
 ob_implicit_flush(1);
51 51
 
52 52
 // load the generated persistence file if found
53 53
 $persistence = array();
54
-if(file_exists($persist = sugar_cached('/modules/UpgradeWizard/_persistence.php'))) {
54
+if (file_exists($persist = sugar_cached('/modules/UpgradeWizard/_persistence.php'))) {
55 55
 	require_once $persist;
56 56
 }
57 57
 require_once('modules/UpgradeWizard/uw_utils.php');
58 58
 require_once('include/utils/zip_utils.php');
59 59
 
60
-switch($_REQUEST['preflightStep']) {
60
+switch ($_REQUEST['preflightStep']) {
61 61
 	case 'find_upgrade_files':
62 62
 		logThis('preflightJson finding upgrade files');
63 63
 		ob_end_flush();
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 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.
@@ -45,8 +47,9 @@  discard block
 block discarded – undo
45 47
  * Reserved. Contributor(s): ______________________________________..
46 48
  * *******************************************************************************/
47 49
 
48
-if(ob_get_level() < 1)
50
+if(ob_get_level() < 1) {
49 51
 	ob_start();
52
+}
50 53
 ob_implicit_flush(1);
51 54
 
52 55
 // load the generated persistence file if found
Please login to merge, or discard this patch.