Passed
Push — scrutinizer-code-quality ( eedb15...27193c )
by Adam
54:15 queued 15s
created
modules/UpgradeWizard/silentUpgrade_dce_step1.php 1 patch
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.
modules/UpgradeWizard/silentUpgrade_step1.php 1 patch
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.
modules/UpgradeWizard/uw_emptyFunctions.php 1 patch
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.
modules/UpgradeWizard/systemCheckJson.php 1 patch
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.
modules/UpgradeWizard/silentUpgrade_step2.php 1 patch
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.
modules/UpgradeWizard/preflightJson.php 1 patch
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.
modules/UpgradeWizard/UploadFileCheck.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
  * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
39 39
  ********************************************************************************/
40 40
 
41
- //Request object must have these property values:
42
- //		Module: module name, this module should have a file called TreeData.php
43
- //		Function: name of the function to be called in TreeData.php, the function will be called statically.
44
- //		PARAM prefixed properties: array of these property/values will be passed to the function as parameter.
41
+    //Request object must have these property values:
42
+    //		Module: module name, this module should have a file called TreeData.php
43
+    //		Function: name of the function to be called in TreeData.php, the function will be called statically.
44
+    //		PARAM prefixed properties: array of these property/values will be passed to the function as parameter.
45 45
 
46 46
 require_once('include/JSON.php');
47 47
 require_once('include/upload_file.php');
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
 $json = getJSONobj();
52 52
 $file_name = $json->decode(html_entity_decode($_REQUEST['file_name']));
53
- if(isset($file_name['jsonObject']) && $file_name['jsonObject'] != null){
54
-	$file_name = $file_name['jsonObject'];
55
-  }
53
+    if(isset($file_name['jsonObject']) && $file_name['jsonObject'] != null){
54
+    $file_name = $file_name['jsonObject'];
55
+    }
56 56
 
57 57
 $filesize = '';
58 58
 if(file_exists($file_name)){
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 //$uploadSizeIni = substr(ini_get("upload_max_filesize"), 0, strlen( ini_get("upload_max_filesize")) - 1);
74 74
 //$GLOBALS['log']->fatal('Upload php setting Size '.return_bytes(ini_get("upload_max_filesize")));
75 75
 if($filesize != null){
76
-	if(($filesize > return_bytes(ini_get("upload_max_filesize"))) || ($filesize > return_bytes(ini_get("post_max_size")))){
77
-		$response=$filesize;
78
-		//$response= "<script>alert('File size is bigger than the max_upload-size setting in php.ini. Upgrade attempt will fail. Increase the upload_max_size in php.ini to greater than ')</script>";
79
-	}
76
+    if(($filesize > return_bytes(ini_get("upload_max_filesize"))) || ($filesize > return_bytes(ini_get("post_max_size")))){
77
+        $response=$filesize;
78
+        //$response= "<script>alert('File size is bigger than the max_upload-size setting in php.ini. Upgrade attempt will fail. Increase the upload_max_size in php.ini to greater than ')</script>";
79
+    }
80 80
 }
81 81
 
82 82
 if (!empty($response)) {
Please login to merge, or discard this patch.
modules/UpgradeWizard/upgradeTimeCounter.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -72,18 +72,18 @@
 block discarded – undo
72 72
  }
73 73
 */
74 74
 
75
- $_SESSION['totalUpgradeTime'] = $_SESSION['totalUpgradeTime']+$_REQUEST['upgradeStepTime'];
76
- $response = $_SESSION['totalUpgradeTime'];
75
+    $_SESSION['totalUpgradeTime'] = $_SESSION['totalUpgradeTime']+$_REQUEST['upgradeStepTime'];
76
+    $response = $_SESSION['totalUpgradeTime'];
77 77
 
78 78
 $GLOBALS['log']->fatal('TOTAL TIME .....'.$_SESSION['totalUpgradeTime']);
79
- //$uptime = $uptime+$_REQUEST['upgradeStepTime'];
80
- $GLOBALS['log']->fatal($response);
79
+    //$uptime = $uptime+$_REQUEST['upgradeStepTime'];
80
+    $GLOBALS['log']->fatal($response);
81 81
 
82 82
 
83
- if (!empty($response)) {
83
+    if (!empty($response)) {
84 84
     $json = getJSONobj();
85
-	print $json->encode($response);
86
- }
85
+    print $json->encode($response);
86
+    }
87 87
 
88 88
 sugar_cleanup();
89 89
 exit();
Please login to merge, or discard this patch.
modules/UpgradeWizard/UpgradeRemoval.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  */
69 69
 public function getFilesToRemove($version)
70 70
 {
71
-	return array();
71
+    return array();
72 72
 }
73 73
 
74 74
 /**
@@ -79,31 +79,31 @@  discard block
 block discarded – undo
79 79
  */
80 80
 public function processFilesToRemove($files=array())
81 81
 {
82
-	if(empty($files) || !is_array($files))
83
-	{
84
-		return;
85
-	}	
82
+    if(empty($files) || !is_array($files))
83
+    {
84
+        return;
85
+    }	
86 86
 	
87
-	require_once('include/dir_inc.php');
87
+    require_once('include/dir_inc.php');
88 88
 	
89
-	if(!file_exists('custom/backup'))
90
-	{
91
-	   mkdir_recursive('custom/backup');
92
-	}
89
+    if(!file_exists('custom/backup'))
90
+    {
91
+        mkdir_recursive('custom/backup');
92
+    }
93 93
 	
94
-	foreach($files as $file)
95
-	{		
96
-		if(file_exists($file))
97
-		{
98
-			$this->backup($file);   
99
-			if(is_dir($file))
100
-			{
101
-			  rmdir_recursive($file);	
102
-			} else {
103
-			  unlink($file);
104
-			}
105
-	    }
106
-	}
94
+    foreach($files as $file)
95
+    {		
96
+        if(file_exists($file))
97
+        {
98
+            $this->backup($file);   
99
+            if(is_dir($file))
100
+            {
101
+                rmdir_recursive($file);	
102
+            } else {
103
+                unlink($file);
104
+            }
105
+        }
106
+    }
107 107
 }
108 108
 
109 109
 
@@ -115,20 +115,20 @@  discard block
 block discarded – undo
115 115
  */
116 116
 protected function backup($file)
117 117
 {
118
-	$basename = basename($file);
119
-	$basepath = str_replace($basename, '', $file);
118
+    $basename = basename($file);
119
+    $basepath = str_replace($basename, '', $file);
120 120
 
121
-	if(!empty($basepath) && !file_exists('custom/backup/' . $basepath))
122
-	{
123
-	   mkdir_recursive('custom/backup/' . $basepath);
124
-	}
121
+    if(!empty($basepath) && !file_exists('custom/backup/' . $basepath))
122
+    {
123
+        mkdir_recursive('custom/backup/' . $basepath);
124
+    }
125 125
 	
126
-	if(is_dir($file))
127
-	{
128
-    	copy_recursive($file, 'custom/backup/' . $file);	
129
-	} else {
130
-		copy($file, 'custom/backup/' . $file);
131
-	}
126
+    if(is_dir($file))
127
+    {
128
+        copy_recursive($file, 'custom/backup/' . $file);	
129
+    } else {
130
+        copy($file, 'custom/backup/' . $file);
131
+    }
132 132
 }
133 133
 
134 134
 }
Please login to merge, or discard this patch.