@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | //// php.exe -f silentUpgrade.php [Path to Upgrade Package zip] [Path to Log file] [Path to Instance] |
43 | 43 | //// See below the Usage for more details. |
44 | 44 | ///////////////////////////////////////////////////////////////////////////////////////// |
45 | -ini_set('memory_limit',-1); |
|
45 | +ini_set('memory_limit', -1); |
|
46 | 46 | /////////////////////////////////////////////////////////////////////////////// |
47 | 47 | //// UTILITIES THAT MUST BE LOCAL :( |
48 | 48 | function prepSystemForUpgradeSilent() { |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | global $sugar_config; |
52 | 52 | |
53 | 53 | // make sure dirs exist |
54 | - foreach($subdirs as $subdir) { |
|
55 | - if(!is_dir($sugar_config['upload_dir']."/upgrades/{$subdir}")) { |
|
54 | + foreach ($subdirs as $subdir) { |
|
55 | + if (!is_dir($sugar_config['upload_dir']."/upgrades/{$subdir}")) { |
|
56 | 56 | mkdir_recursive($sugar_config['upload_dir']."/upgrades/{$subdir}"); |
57 | 57 | } |
58 | 58 | } |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | if ($current = @opendir($thedir)) { |
64 | 64 | while (false !== ($children = readdir($current))) { |
65 | 65 | if ($children != "." && $children != "..") { |
66 | - if (is_dir($thedir . "/" . $children)) { |
|
67 | - clearCacheSU($thedir . "/" . $children, $extension); |
|
66 | + if (is_dir($thedir."/".$children)) { |
|
67 | + clearCacheSU($thedir."/".$children, $extension); |
|
68 | 68 | } |
69 | - elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) { |
|
70 | - unlink($thedir . "/" . $children); |
|
69 | + elseif (is_file($thedir."/".$children) && substr_count($children, $extension)) { |
|
70 | + unlink($thedir."/".$children); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
@@ -75,34 +75,34 @@ discard block |
||
75 | 75 | } |
76 | 76 | //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if |
77 | 77 | //no found then adds default_permissions to the config file. |
78 | - function checkConfigForPermissions(){ |
|
79 | - if(file_exists(getcwd().'/config.php')){ |
|
78 | + function checkConfigForPermissions() { |
|
79 | + if (file_exists(getcwd().'/config.php')) { |
|
80 | 80 | require(getcwd().'/config.php'); |
81 | 81 | } |
82 | 82 | global $sugar_config; |
83 | - if(!isset($sugar_config['default_permissions'])){ |
|
84 | - $sugar_config['default_permissions'] = array ( |
|
83 | + if (!isset($sugar_config['default_permissions'])) { |
|
84 | + $sugar_config['default_permissions'] = array( |
|
85 | 85 | 'dir_mode' => 02770, |
86 | 86 | 'file_mode' => 0660, |
87 | 87 | 'user' => '', |
88 | 88 | 'group' => '', |
89 | 89 | ); |
90 | 90 | ksort($sugar_config); |
91 | - if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) { |
|
91 | + if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) { |
|
92 | 92 | //writing to the file |
93 | 93 | } |
94 | 94 | } |
95 | 95 | } |
96 | -function checkLoggerSettings(){ |
|
97 | - if(file_exists(getcwd().'/config.php')){ |
|
96 | +function checkLoggerSettings() { |
|
97 | + if (file_exists(getcwd().'/config.php')) { |
|
98 | 98 | require(getcwd().'/config.php'); |
99 | 99 | } |
100 | 100 | global $sugar_config; |
101 | - if(!isset($sugar_config['logger'])){ |
|
102 | - $sugar_config['logger'] =array ( |
|
101 | + if (!isset($sugar_config['logger'])) { |
|
102 | + $sugar_config['logger'] = array( |
|
103 | 103 | 'level'=>'fatal', |
104 | 104 | 'file' => |
105 | - array ( |
|
105 | + array( |
|
106 | 106 | 'ext' => '.log', |
107 | 107 | 'name' => 'sugarcrm', |
108 | 108 | 'dateFormat' => '%c', |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | ), |
113 | 113 | ); |
114 | 114 | ksort($sugar_config); |
115 | - if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) { |
|
115 | + if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) { |
|
116 | 116 | //writing to the file |
117 | 117 | } |
118 | 118 | } |
@@ -126,23 +126,23 @@ discard block |
||
126 | 126 | if (!isset($sugar_config['lead_conv_activity_opt'])) { |
127 | 127 | $sugar_config['lead_conv_activity_opt'] = 'copy'; |
128 | 128 | ksort($sugar_config); |
129 | - if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) { |
|
129 | + if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) { |
|
130 | 130 | //writing to the file |
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | -function checkResourceSettings(){ |
|
136 | - if(file_exists(getcwd().'/config.php')){ |
|
135 | +function checkResourceSettings() { |
|
136 | + if (file_exists(getcwd().'/config.php')) { |
|
137 | 137 | require(getcwd().'/config.php'); |
138 | 138 | } |
139 | 139 | global $sugar_config; |
140 | - if(!isset($sugar_config['resource_management'])){ |
|
140 | + if (!isset($sugar_config['resource_management'])) { |
|
141 | 141 | $sugar_config['resource_management'] = |
142 | - array ( |
|
142 | + array( |
|
143 | 143 | 'special_query_limit' => 50000, |
144 | 144 | 'special_query_modules' => |
145 | - array ( |
|
145 | + array( |
|
146 | 146 | 0 => 'Reports', |
147 | 147 | 1 => 'Export', |
148 | 148 | 2 => 'Import', |
@@ -152,23 +152,23 @@ discard block |
||
152 | 152 | 'default_limit' => 1000, |
153 | 153 | ); |
154 | 154 | ksort($sugar_config); |
155 | - if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) { |
|
155 | + if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) { |
|
156 | 156 | //writing to the file |
157 | 157 | } |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | -function createMissingRels(){ |
|
163 | - $relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects'); |
|
164 | - foreach($relForObjects as $relObjName=>$relModName){ |
|
162 | +function createMissingRels() { |
|
163 | + $relForObjects = array('leads'=>'Leads', 'campaigns'=>'Campaigns', 'prospects'=>'Prospects'); |
|
164 | + foreach ($relForObjects as $relObjName=>$relModName) { |
|
165 | 165 | //assigned_user |
166 | 166 | $guid = create_guid(); |
167 | 167 | $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'"; |
168 | - $result= $GLOBALS['db']->query($query, true); |
|
168 | + $result = $GLOBALS['db']->query($query, true); |
|
169 | 169 | $a = null; |
170 | 170 | $a = $GLOBALS['db']->fetchByAssoc($result); |
171 | - if(!isset($a['id']) && empty($a['id']) ){ |
|
171 | + if (!isset($a['id']) && empty($a['id'])) { |
|
172 | 172 | $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted) |
173 | 173 | VALUES ('{$guid}', '{$relObjName}_assigned_user','Users','users','id','{$relModName}','{$relObjName}','assigned_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')"; |
174 | 174 | $GLOBALS['db']->query($qRel); |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | //modified_user |
177 | 177 | $guid = create_guid(); |
178 | 178 | $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'"; |
179 | - $result= $GLOBALS['db']->query($query, true); |
|
179 | + $result = $GLOBALS['db']->query($query, true); |
|
180 | 180 | $a = null; |
181 | 181 | $a = $GLOBALS['db']->fetchByAssoc($result); |
182 | - if(!isset($a['id']) && empty($a['id']) ){ |
|
182 | + if (!isset($a['id']) && empty($a['id'])) { |
|
183 | 183 | $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted) |
184 | 184 | VALUES ('{$guid}', '{$relObjName}_modified_user','Users','users','id','{$relModName}','{$relObjName}','modified_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')"; |
185 | 185 | $GLOBALS['db']->query($qRel); |
@@ -187,20 +187,20 @@ discard block |
||
187 | 187 | //created_by |
188 | 188 | $guid = create_guid(); |
189 | 189 | $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'"; |
190 | - $result= $GLOBALS['db']->query($query, true); |
|
190 | + $result = $GLOBALS['db']->query($query, true); |
|
191 | 191 | $a = null; |
192 | 192 | $a = $GLOBALS['db']->fetchByAssoc($result); |
193 | - if(!isset($a['id']) && empty($a['id']) ){ |
|
193 | + if (!isset($a['id']) && empty($a['id'])) { |
|
194 | 194 | $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted) |
195 | 195 | VALUES ('{$guid}', '{$relObjName}_created_by','Users','users','id','{$relModName}','{$relObjName}','created_by',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')"; |
196 | 196 | $GLOBALS['db']->query($qRel); |
197 | 197 | } |
198 | 198 | $guid = create_guid(); |
199 | 199 | $query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_team'"; |
200 | - $result= $GLOBALS['db']->query($query, true); |
|
200 | + $result = $GLOBALS['db']->query($query, true); |
|
201 | 201 | $a = null; |
202 | 202 | $a = $GLOBALS['db']->fetchByAssoc($result); |
203 | - if(!isset($a['id']) && empty($a['id']) ){ |
|
203 | + if (!isset($a['id']) && empty($a['id'])) { |
|
204 | 204 | $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted) |
205 | 205 | VALUES ('{$guid}', '{$relObjName}_team','Teams','teams','id','{$relModName}','{$relObjName}','team_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')"; |
206 | 206 | $GLOBALS['db']->query($qRel); |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | //Also add tracker perf relationship |
210 | 210 | $guid = create_guid(); |
211 | 211 | $query = "SELECT id FROM relationships WHERE relationship_name = 'tracker_monitor_id'"; |
212 | - $result= $GLOBALS['db']->query($query, true); |
|
212 | + $result = $GLOBALS['db']->query($query, true); |
|
213 | 213 | $a = null; |
214 | 214 | $a = $GLOBALS['db']->fetchByAssoc($result); |
215 | - if(!isset($a['id']) && empty($a['id']) ){ |
|
215 | + if (!isset($a['id']) && empty($a['id'])) { |
|
216 | 216 | $qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted) |
217 | 217 | VALUES ('{$guid}', 'tracker_monitor_id','TrackerPerfs','tracker_perf','monitor_id','Trackers','tracker','monitor_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')"; |
218 | 218 | $GLOBALS['db']->query($qRel); |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | */ |
229 | 229 | function merge_passwordsetting($sugar_config, $sugar_version) { |
230 | 230 | |
231 | - $passwordsetting_defaults = array ( |
|
232 | - 'passwordsetting' => array ( |
|
231 | + $passwordsetting_defaults = array( |
|
232 | + 'passwordsetting' => array( |
|
233 | 233 | 'minpwdlength' => '', |
234 | 234 | 'maxpwdlength' => '', |
235 | 235 | 'oneupper' => '', |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | ), |
261 | 261 | ); |
262 | 262 | |
263 | - $sugar_config = sugarArrayMerge($passwordsetting_defaults, $sugar_config ); |
|
263 | + $sugar_config = sugarArrayMerge($passwordsetting_defaults, $sugar_config); |
|
264 | 264 | |
265 | 265 | // need to override version with default no matter what |
266 | 266 | $sugar_config['sugar_version'] = $sugar_version; |
267 | 267 | |
268 | - ksort( $sugar_config ); |
|
268 | + ksort($sugar_config); |
|
269 | 269 | |
270 | - if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){ |
|
270 | + if (write_array_to_file("sugar_config", $sugar_config, "config.php")) { |
|
271 | 271 | return true; |
272 | 272 | } |
273 | 273 | else { |
@@ -276,17 +276,17 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | function addDefaultModuleRoles($defaultRoles = array()) { |
279 | - foreach($defaultRoles as $roleName=>$role){ |
|
280 | - foreach($role as $category=>$actions){ |
|
281 | - foreach($actions as $name=>$access_override){ |
|
279 | + foreach ($defaultRoles as $roleName=>$role) { |
|
280 | + foreach ($role as $category=>$actions) { |
|
281 | + foreach ($actions as $name=>$access_override) { |
|
282 | 282 | $query = "SELECT * FROM acl_actions WHERE name='$name' AND category = '$category' AND acltype='$roleName' AND deleted=0 "; |
283 | 283 | $result = $GLOBALS['db']->query($query); |
284 | 284 | //only add if an action with that name and category don't exist |
285 | - $row=$GLOBALS['db']->fetchByAssoc($result); |
|
285 | + $row = $GLOBALS['db']->fetchByAssoc($result); |
|
286 | 286 | if ($row == null) { |
287 | 287 | $guid = create_guid(); |
288 | 288 | $currdate = gmdate('Y-m-d H:i:s'); |
289 | - $query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')"; |
|
289 | + $query = "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')"; |
|
290 | 290 | $GLOBALS['db']->query($query); |
291 | 291 | } |
292 | 292 | } |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | } |
295 | 295 | } |
296 | 296 | |
297 | -function verifyArguments($argv,$usage_regular){ |
|
297 | +function verifyArguments($argv, $usage_regular) { |
|
298 | 298 | $upgradeType = ''; |
299 | 299 | $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir. |
300 | - if(isset($argv[3])) { |
|
301 | - if(is_dir($argv[3])) { |
|
300 | + if (isset($argv[3])) { |
|
301 | + if (is_dir($argv[3])) { |
|
302 | 302 | $cwd = $argv[3]; |
303 | 303 | chdir($cwd); |
304 | 304 | } else { |
@@ -308,18 +308,18 @@ discard block |
||
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
311 | - if(is_file("{$cwd}/include/entryPoint.php")) { |
|
311 | + if (is_file("{$cwd}/include/entryPoint.php")) { |
|
312 | 312 | //this should be a regular sugar install |
313 | 313 | $upgradeType = constant('SUGARCRM_INSTALL'); |
314 | 314 | //check if this is a valid zip file |
315 | - if(!is_file($argv[1])) { // valid zip? |
|
315 | + if (!is_file($argv[1])) { // valid zip? |
|
316 | 316 | echo "*******************************************************************************\n"; |
317 | 317 | echo "*** ERROR: First argument must be a full path to the patch file. Got [ {$argv[1]} ].\n"; |
318 | 318 | echo $usage_regular; |
319 | 319 | echo "FAILURE\n"; |
320 | 320 | exit(1); |
321 | 321 | } |
322 | - if(count($argv) < 5) { |
|
322 | + if (count($argv) < 5) { |
|
323 | 323 | echo "*******************************************************************************\n"; |
324 | 324 | echo "*** ERROR: Missing required parameters. Received ".count($argv)." argument(s), require 5.\n"; |
325 | 325 | echo $usage_regular; |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | exit(1); |
334 | 334 | } |
335 | 335 | |
336 | - if(isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')){ |
|
336 | + if (isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')) { |
|
337 | 337 | require_once($argv[7].'SugarTemplateUtilties.php'); |
338 | 338 | } |
339 | 339 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | |
344 | 344 | |
345 | -function threeWayMerge(){ |
|
345 | +function threeWayMerge() { |
|
346 | 346 | //using threeway merge apis |
347 | 347 | } |
348 | 348 | |
@@ -357,14 +357,14 @@ discard block |
||
357 | 357 | //End of #52872 |
358 | 358 | |
359 | 359 | // only run from command line |
360 | -if(isset($_SERVER['HTTP_USER_AGENT'])) { |
|
361 | - fwrite(STDERR,'This utility may only be run from the command line or command prompt.'); |
|
360 | +if (isset($_SERVER['HTTP_USER_AGENT'])) { |
|
361 | + fwrite(STDERR, 'This utility may only be run from the command line or command prompt.'); |
|
362 | 362 | exit(1); |
363 | 363 | } |
364 | 364 | //Clean_string cleans out any file passed in as a parameter |
365 | 365 | $_SERVER['PHP_SELF'] = 'silentUpgrade.php'; |
366 | 366 | |
367 | -$usage_regular =<<<eoq2 |
|
367 | +$usage_regular = <<<eoq2 |
|
368 | 368 | Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance] [admin-user] |
369 | 369 | |
370 | 370 | On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | |
387 | 387 | /////////////////////////////////////////////////////////////////////////////// |
388 | 388 | //// STANDARD REQUIRED SUGAR INCLUDES AND PRESETS |
389 | -if(!defined('sugarEntry')) define('sugarEntry', true); |
|
389 | +if (!defined('sugarEntry')) define('sugarEntry', true); |
|
390 | 390 | |
391 | 391 | $_SESSION = array(); |
392 | 392 | $_SESSION['schema_change'] = 'sugar'; // we force-run all SQL |
@@ -403,13 +403,13 @@ discard block |
||
403 | 403 | global $cwd; |
404 | 404 | $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir. |
405 | 405 | |
406 | -$upgradeType = verifyArguments($argv,$usage_regular); |
|
406 | +$upgradeType = verifyArguments($argv, $usage_regular); |
|
407 | 407 | |
408 | 408 | /////////////////////////////////////////////////////////////////////////////// |
409 | 409 | ////// Verify that all the arguments are appropriately placed//////////////// |
410 | 410 | |
411 | -$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log |
|
412 | -$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); |
|
411 | +$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log |
|
412 | +$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); |
|
413 | 413 | |
414 | 414 | //$_REQUEST['zip_from_dir'] = $zip_from_dir; |
415 | 415 | |
@@ -431,15 +431,15 @@ discard block |
||
431 | 431 | $errors = array(); |
432 | 432 | |
433 | 433 | |
434 | -if($upgradeType != constant('DCE_INSTANCE')) { |
|
434 | +if ($upgradeType != constant('DCE_INSTANCE')) { |
|
435 | 435 | |
436 | - ini_set('error_reporting',1); |
|
436 | + ini_set('error_reporting', 1); |
|
437 | 437 | require_once('include/entryPoint.php'); |
438 | 438 | require_once('include/SugarLogger/SugarLogger.php'); |
439 | 439 | require_once('include/utils/zip_utils.php'); |
440 | 440 | |
441 | 441 | |
442 | -if(!function_exists('sugar_cached')) |
|
442 | +if (!function_exists('sugar_cached')) |
|
443 | 443 | { |
444 | 444 | /** |
445 | 445 | * sugar_cached |
@@ -450,10 +450,10 @@ discard block |
||
450 | 450 | function sugar_cached($file) |
451 | 451 | { |
452 | 452 | static $cdir = null; |
453 | - if(empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) { |
|
453 | + if (empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) { |
|
454 | 454 | $cdir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); |
455 | 455 | } |
456 | - if(empty($cdir)) { |
|
456 | + if (empty($cdir)) { |
|
457 | 457 | $cdir = "cache"; |
458 | 458 | } |
459 | 459 | return "$cdir/$file"; |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | |
463 | 463 | require('config.php'); |
464 | 464 | //require_once('modules/UpgradeWizard/uw_utils.php'); // must upgrade UW first |
465 | - if(isset($argv[3])) { |
|
466 | - if(is_dir($argv[3])) { |
|
465 | + if (isset($argv[3])) { |
|
466 | + if (is_dir($argv[3])) { |
|
467 | 467 | $cwd = $argv[3]; |
468 | 468 | chdir($cwd); |
469 | 469 | } |
@@ -471,37 +471,37 @@ discard block |
||
471 | 471 | |
472 | 472 | require_once("{$cwd}/sugar_version.php"); // provides $sugar_version & $sugar_flavor |
473 | 473 | |
474 | - $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM'); |
|
475 | - $patchName = basename($argv[1]); |
|
476 | - $zip_from_dir = substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip") |
|
477 | - $path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log |
|
474 | + $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM'); |
|
475 | + $patchName = basename($argv[1]); |
|
476 | + $zip_from_dir = substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip") |
|
477 | + $path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log |
|
478 | 478 | |
479 | - $db = &DBManagerFactory::getInstance(); |
|
480 | - $UWstrings = return_module_language('en_us', 'UpgradeWizard'); |
|
481 | - $adminStrings = return_module_language('en_us', 'Administration'); |
|
479 | + $db = &DBManagerFactory::getInstance(); |
|
480 | + $UWstrings = return_module_language('en_us', 'UpgradeWizard'); |
|
481 | + $adminStrings = return_module_language('en_us', 'Administration'); |
|
482 | 482 | $app_list_strings = return_app_list_strings_language('en_us'); |
483 | - $mod_strings = array_merge($adminStrings, $UWstrings); |
|
484 | - $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); |
|
483 | + $mod_strings = array_merge($adminStrings, $UWstrings); |
|
484 | + $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); |
|
485 | 485 | global $unzip_dir; |
486 | 486 | $license_accepted = false; |
487 | - if(isset($argv[5]) && (strtolower($argv[5])=='yes' || strtolower($argv[5])=='y')){ |
|
487 | + if (isset($argv[5]) && (strtolower($argv[5]) == 'yes' || strtolower($argv[5]) == 'y')) { |
|
488 | 488 | $license_accepted = true; |
489 | 489 | } |
490 | 490 | ////////////////////////////////////////////////////////////////////////////// |
491 | 491 | //Adding admin user to the silent upgrade |
492 | 492 | |
493 | 493 | $current_user = new User(); |
494 | - if(isset($argv[4])) { |
|
494 | + if (isset($argv[4])) { |
|
495 | 495 | //if being used for internal upgrades avoid admin user verification |
496 | 496 | $user_name = $argv[4]; |
497 | - $q = "select id from users where user_name = '" . $user_name . "' and is_admin=1"; |
|
497 | + $q = "select id from users where user_name = '".$user_name."' and is_admin=1"; |
|
498 | 498 | $result = $GLOBALS['db']->query($q, false); |
499 | 499 | $logged_user = $GLOBALS['db']->fetchByAssoc($result); |
500 | - if(isset($logged_user['id']) && $logged_user['id'] != null){ |
|
500 | + if (isset($logged_user['id']) && $logged_user['id'] != null) { |
|
501 | 501 | //do nothing |
502 | 502 | $current_user->retrieve($logged_user['id']); |
503 | 503 | } |
504 | - else{ |
|
504 | + else { |
|
505 | 505 | echo "FAILURE: Not an admin user in users table. Please provide an admin user\n"; |
506 | 506 | exit(1); |
507 | 507 | } |
@@ -533,18 +533,18 @@ discard block |
||
533 | 533 | $_SESSION['unzip_dir'] = $unzip_dir; |
534 | 534 | $_SESSION['install_file'] = $install_file; |
535 | 535 | $_SESSION['zip_from_dir'] = $zip_from_dir; |
536 | -if(is_dir($unzip_dir.'/scripts')) |
|
536 | +if (is_dir($unzip_dir.'/scripts')) |
|
537 | 537 | { |
538 | 538 | rmdir_recursive($unzip_dir.'/scripts'); |
539 | 539 | } |
540 | -if(is_file($unzip_dir.'/manifest.php')) |
|
540 | +if (is_file($unzip_dir.'/manifest.php')) |
|
541 | 541 | { |
542 | 542 | rmdir_recursive($unzip_dir.'/manifest.php'); |
543 | 543 | } |
544 | 544 | mkdir_recursive($unzip_dir); |
545 | -if(!is_dir($unzip_dir)) { |
|
545 | +if (!is_dir($unzip_dir)) { |
|
546 | 546 | echo "\n{$unzip_dir} is not an available directory\nFAILURE\n"; |
547 | - fwrite(STDERR,"\n{$unzip_dir} is not an available directory\nFAILURE\n"); |
|
547 | + fwrite(STDERR, "\n{$unzip_dir} is not an available directory\nFAILURE\n"); |
|
548 | 548 | exit(1); |
549 | 549 | } |
550 | 550 | |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | $uwFiles = findAllFiles("{$zipBasePath}/modules/UpgradeWizard", array()); |
562 | 562 | $destFiles = array(); |
563 | 563 | |
564 | -foreach($uwFiles as $uwFile) { |
|
564 | +foreach ($uwFiles as $uwFile) { |
|
565 | 565 | $destFile = str_replace($zipBasePath."/", '', $uwFile); |
566 | 566 | copy($uwFile, $destFile); |
567 | 567 | } |
@@ -570,17 +570,17 @@ discard block |
||
570 | 570 | logThis("*** SILENT UPGRADE INITIATED.", $path); |
571 | 571 | logThis("*** UpgradeWizard Upgraded ", $path); |
572 | 572 | |
573 | -if(function_exists('set_upgrade_vars')){ |
|
573 | +if (function_exists('set_upgrade_vars')) { |
|
574 | 574 | set_upgrade_vars(); |
575 | 575 | } |
576 | 576 | |
577 | -if($configOptions['db_type'] == 'mysql'){ |
|
577 | +if ($configOptions['db_type'] == 'mysql') { |
|
578 | 578 | //Change the db wait_timeout for this session |
579 | 579 | $now_timeout = $db->getOne("select @@wait_timeout"); |
580 | - logThis('Wait Timeout before change ***** '.$now_timeout , $path); |
|
580 | + logThis('Wait Timeout before change ***** '.$now_timeout, $path); |
|
581 | 581 | $db->query("set wait_timeout=28800"); |
582 | 582 | $now_timeout = $db->getOne("select @@wait_timeout"); |
583 | - logThis('Wait Timeout after change ***** '.$now_timeout , $path); |
|
583 | + logThis('Wait Timeout after change ***** '.$now_timeout, $path); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | //// END UPGRADE UPGRADEWIZARD |
@@ -588,24 +588,24 @@ discard block |
||
588 | 588 | |
589 | 589 | /////////////////////////////////////////////////////////////////////////////// |
590 | 590 | //// MAKE SURE PATCH IS COMPATIBLE |
591 | -if(is_file("$unzip_dir/manifest.php")) { |
|
591 | +if (is_file("$unzip_dir/manifest.php")) { |
|
592 | 592 | // provides $manifest array |
593 | 593 | include("$unzip_dir/manifest.php"); |
594 | - if(!isset($manifest)) { |
|
595 | - fwrite(STDERR,"\nThe patch did not contain a proper manifest.php file. Cannot continue.\n\n"); |
|
594 | + if (!isset($manifest)) { |
|
595 | + fwrite(STDERR, "\nThe patch did not contain a proper manifest.php file. Cannot continue.\n\n"); |
|
596 | 596 | exit(1); |
597 | 597 | } else { |
598 | 598 | copy("$unzip_dir/manifest.php", $sugar_config['upload_dir']."/upgrades/patch/{$zip_from_dir}-manifest.php"); |
599 | 599 | |
600 | 600 | $error = validate_manifest($manifest); |
601 | - if(!empty($error)) { |
|
601 | + if (!empty($error)) { |
|
602 | 602 | $error = strip_tags(br2nl($error)); |
603 | - fwrite(STDERR,"\n{$error}\n\nFAILURE\n"); |
|
603 | + fwrite(STDERR, "\n{$error}\n\nFAILURE\n"); |
|
604 | 604 | exit(1); |
605 | 605 | } |
606 | 606 | } |
607 | 607 | } else { |
608 | - fwrite(STDERR,"\nThe patch did not contain a proper manifest.php file. Cannot continue.\n\n"); |
|
608 | + fwrite(STDERR, "\nThe patch did not contain a proper manifest.php file. Cannot continue.\n\n"); |
|
609 | 609 | exit(1); |
610 | 610 | } |
611 | 611 | |
@@ -623,17 +623,17 @@ discard block |
||
623 | 623 | //// RUN SILENT UPGRADE |
624 | 624 | ob_start(); |
625 | 625 | set_time_limit(0); |
626 | -if(file_exists('ModuleInstall/PackageManager/PackageManagerDisplay.php')) { |
|
626 | +if (file_exists('ModuleInstall/PackageManager/PackageManagerDisplay.php')) { |
|
627 | 627 | require_once('ModuleInstall/PackageManager/PackageManagerDisplay.php'); |
628 | 628 | } |
629 | 629 | |
630 | 630 | |
631 | 631 | //copy minimum required files including sugar_file_utils.php |
632 | - if(file_exists("{$zipBasePath}/include/utils/sugar_file_utils.php")){ |
|
632 | + if (file_exists("{$zipBasePath}/include/utils/sugar_file_utils.php")) { |
|
633 | 633 | $destFile = clean_path(str_replace($zipBasePath, $cwd, "{$zipBasePath}/include/utils/sugar_file_utils.php")); |
634 | 634 | copy("{$zipBasePath}/include/utils/sugar_file_utils.php", $destFile); |
635 | 635 | } |
636 | - if(file_exists('include/utils/sugar_file_utils.php')){ |
|
636 | + if (file_exists('include/utils/sugar_file_utils.php')) { |
|
637 | 637 | require_once('include/utils/sugar_file_utils.php'); |
638 | 638 | } |
639 | 639 | |
@@ -648,60 +648,60 @@ discard block |
||
648 | 648 | } |
649 | 649 | */ |
650 | 650 | //If version less than 500 then look for modules to be upgraded |
651 | -if(function_exists('set_upgrade_vars')){ |
|
651 | +if (function_exists('set_upgrade_vars')) { |
|
652 | 652 | set_upgrade_vars(); |
653 | 653 | } |
654 | 654 | //Initialize the session variables. If upgrade_progress.php is already created |
655 | 655 | //look for session vars there and restore them |
656 | -if(function_exists('initialize_session_vars')){ |
|
656 | +if (function_exists('initialize_session_vars')) { |
|
657 | 657 | initialize_session_vars(); |
658 | 658 | } |
659 | 659 | |
660 | -if(!didThisStepRunBefore('preflight')){ |
|
661 | - set_upgrade_progress('preflight','in_progress'); |
|
660 | +if (!didThisStepRunBefore('preflight')) { |
|
661 | + set_upgrade_progress('preflight', 'in_progress'); |
|
662 | 662 | //Quickcreatedefs on the basis of editviewdefs |
663 | 663 | updateQuickCreateDefs(); |
664 | - set_upgrade_progress('preflight','done'); |
|
664 | + set_upgrade_progress('preflight', 'done'); |
|
665 | 665 | } |
666 | 666 | ////////////////COMMIT PROCESS BEGINS/////////////////////////////////////////////////////////////// |
667 | 667 | //// MAKE BACKUPS OF TARGET FILES |
668 | 668 | |
669 | -if(!didThisStepRunBefore('commit')){ |
|
670 | - set_upgrade_progress('commit','in_progress','commit','in_progress'); |
|
671 | - if(!didThisStepRunBefore('commit','commitMakeBackupFiles')){ |
|
672 | - set_upgrade_progress('commit','in_progress','commitMakeBackupFiles','in_progress'); |
|
669 | +if (!didThisStepRunBefore('commit')) { |
|
670 | + set_upgrade_progress('commit', 'in_progress', 'commit', 'in_progress'); |
|
671 | + if (!didThisStepRunBefore('commit', 'commitMakeBackupFiles')) { |
|
672 | + set_upgrade_progress('commit', 'in_progress', 'commitMakeBackupFiles', 'in_progress'); |
|
673 | 673 | $errors = commitMakeBackupFiles($rest_dir, $install_file, $unzip_dir, $zip_from_dir, array()); |
674 | - set_upgrade_progress('commit','in_progress','commitMakeBackupFiles','done'); |
|
674 | + set_upgrade_progress('commit', 'in_progress', 'commitMakeBackupFiles', 'done'); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | //Need to make sure we have the matching copy of SetValueAction for static/instance method matching |
678 | - if(file_exists("include/Expressions/Actions/SetValueAction.php")){ |
|
678 | + if (file_exists("include/Expressions/Actions/SetValueAction.php")) { |
|
679 | 679 | require_once("include/Expressions/Actions/SetValueAction.php"); |
680 | 680 | } |
681 | 681 | |
682 | 682 | /////////////////////////////////////////////////////////////////////////////// |
683 | 683 | //// HANDLE PREINSTALL SCRIPTS |
684 | - if(empty($errors)) { |
|
684 | + if (empty($errors)) { |
|
685 | 685 | $file = "{$unzip_dir}/".constant('SUGARCRM_PRE_INSTALL_FILE'); |
686 | 686 | |
687 | - if(is_file($file)) { |
|
687 | + if (is_file($file)) { |
|
688 | 688 | include($file); |
689 | - if(!didThisStepRunBefore('commit','pre_install')){ |
|
690 | - set_upgrade_progress('commit','in_progress','pre_install','in_progress'); |
|
689 | + if (!didThisStepRunBefore('commit', 'pre_install')) { |
|
690 | + set_upgrade_progress('commit', 'in_progress', 'pre_install', 'in_progress'); |
|
691 | 691 | pre_install(); |
692 | - set_upgrade_progress('commit','in_progress','pre_install','done'); |
|
692 | + set_upgrade_progress('commit', 'in_progress', 'pre_install', 'done'); |
|
693 | 693 | } |
694 | 694 | } |
695 | 695 | } |
696 | 696 | |
697 | 697 | //Clean smarty from cache |
698 | 698 | $cachedir = sugar_cached('smarty'); |
699 | - if(is_dir($cachedir)){ |
|
699 | + if (is_dir($cachedir)) { |
|
700 | 700 | $allModFiles = array(); |
701 | - $allModFiles = findAllFiles($cachedir,$allModFiles); |
|
702 | - foreach($allModFiles as $file){ |
|
701 | + $allModFiles = findAllFiles($cachedir, $allModFiles); |
|
702 | + foreach ($allModFiles as $file) { |
|
703 | 703 | //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
704 | - if(file_exists($file)){ |
|
704 | + if (file_exists($file)) { |
|
705 | 705 | unlink($file); |
706 | 706 | } |
707 | 707 | } |
@@ -709,29 +709,29 @@ discard block |
||
709 | 709 | |
710 | 710 | //Also add the three-way merge here. The idea is after the 451 html files have |
711 | 711 | //been converted run the 3-way merge. If 500 then just run the 3-way merge |
712 | - if(file_exists('modules/UpgradeWizard/SugarMerge/SugarMerge.php')){ |
|
713 | - set_upgrade_progress('end','in_progress','threewaymerge','in_progress'); |
|
712 | + if (file_exists('modules/UpgradeWizard/SugarMerge/SugarMerge.php')) { |
|
713 | + set_upgrade_progress('end', 'in_progress', 'threewaymerge', 'in_progress'); |
|
714 | 714 | require_once('modules/UpgradeWizard/SugarMerge/SugarMerge.php'); |
715 | 715 | $merger = new SugarMerge($zipBasePath); |
716 | 716 | $merger->mergeAll(); |
717 | - set_upgrade_progress('end','in_progress','threewaymerge','done'); |
|
717 | + set_upgrade_progress('end', 'in_progress', 'threewaymerge', 'done'); |
|
718 | 718 | } |
719 | 719 | /////////////////////////////////////////////////////////////////////////////// |
720 | 720 | //// COPY NEW FILES INTO TARGET INSTANCE |
721 | 721 | |
722 | - if(!didThisStepRunBefore('commit','commitCopyNewFiles')){ |
|
723 | - set_upgrade_progress('commit','in_progress','commitCopyNewFiles','in_progress'); |
|
722 | + if (!didThisStepRunBefore('commit', 'commitCopyNewFiles')) { |
|
723 | + set_upgrade_progress('commit', 'in_progress', 'commitCopyNewFiles', 'in_progress'); |
|
724 | 724 | $split = commitCopyNewFiles($unzip_dir, $zip_from_dir); |
725 | 725 | $copiedFiles = $split['copiedFiles']; |
726 | 726 | $skippedFiles = $split['skippedFiles']; |
727 | - set_upgrade_progress('commit','in_progress','commitCopyNewFiles','done'); |
|
727 | + set_upgrade_progress('commit', 'in_progress', 'commitCopyNewFiles', 'done'); |
|
728 | 728 | } |
729 | 729 | require_once(clean_path($unzip_dir.'/scripts/upgrade_utils.php')); |
730 | 730 | $new_sugar_version = getUpgradeVersion(); |
731 | 731 | $siv_varset_1 = setSilentUpgradeVar('origVersion', $sugar_version); |
732 | 732 | $siv_varset_2 = setSilentUpgradeVar('destVersion', $new_sugar_version); |
733 | 733 | $siv_write = writeSilentUpgradeVars(); |
734 | - if(!$siv_varset_1 || !$siv_varset_2 || !$siv_write){ |
|
734 | + if (!$siv_varset_1 || !$siv_varset_2 || !$siv_write) { |
|
735 | 735 | logThis("Error with silent upgrade variables: origVersion write success is ({$siv_varset_1}) ". |
736 | 736 | "-- destVersion write success is ({$siv_varset_2}) -- ". |
737 | 737 | "writeSilentUpgradeVars success is ({$siv_write}) -- ". |
@@ -754,29 +754,29 @@ discard block |
||
754 | 754 | } |
755 | 755 | /////////////////////////////////////////////////////////////////////////////// |
756 | 756 | //// HANDLE POSTINSTALL SCRIPTS |
757 | - if(empty($errors)) { |
|
757 | + if (empty($errors)) { |
|
758 | 758 | logThis('Starting post_install()...', $path); |
759 | 759 | |
760 | 760 | $trackerManager = TrackerManager::getInstance(); |
761 | 761 | $trackerManager->pause(); |
762 | 762 | $trackerManager->unsetMonitors(); |
763 | 763 | |
764 | - if(!didThisStepRunBefore('commit','post_install')){ |
|
765 | - $file = "$unzip_dir/" . constant('SUGARCRM_POST_INSTALL_FILE'); |
|
766 | - if(is_file($file)) { |
|
764 | + if (!didThisStepRunBefore('commit', 'post_install')) { |
|
765 | + $file = "$unzip_dir/".constant('SUGARCRM_POST_INSTALL_FILE'); |
|
766 | + if (is_file($file)) { |
|
767 | 767 | //set_upgrade_progress('commit','in_progress','post_install','in_progress'); |
768 | - $progArray['post_install']='in_progress'; |
|
769 | - post_install_progress($progArray,'set'); |
|
768 | + $progArray['post_install'] = 'in_progress'; |
|
769 | + post_install_progress($progArray, 'set'); |
|
770 | 770 | global $moduleList; |
771 | 771 | include($file); |
772 | 772 | post_install(); |
773 | 773 | // cn: only run conversion if admin selects "Sugar runs SQL" |
774 | - if(!empty($_SESSION['allTables']) && $_SESSION['schema_change'] == 'sugar') |
|
774 | + if (!empty($_SESSION['allTables']) && $_SESSION['schema_change'] == 'sugar') |
|
775 | 775 | executeConvertTablesSql($_SESSION['allTables']); |
776 | 776 | //set process to done |
777 | - $progArray['post_install']='done'; |
|
777 | + $progArray['post_install'] = 'done'; |
|
778 | 778 | //set_upgrade_progress('commit','in_progress','post_install','done'); |
779 | - post_install_progress($progArray,'set'); |
|
779 | + post_install_progress($progArray, 'set'); |
|
780 | 780 | } |
781 | 781 | } |
782 | 782 | //clean vardefs |
@@ -807,19 +807,19 @@ discard block |
||
807 | 807 | require('config.php'); |
808 | 808 | global $sugar_config; |
809 | 809 | |
810 | - if($ce_to_pro_ent){ |
|
811 | - if(isset($sugar_config['sugarbeet'])) |
|
810 | + if ($ce_to_pro_ent) { |
|
811 | + if (isset($sugar_config['sugarbeet'])) |
|
812 | 812 | { |
813 | 813 | //$sugar_config['sugarbeet'] is only set in COMM |
814 | 814 | unset($sugar_config['sugarbeet']); |
815 | 815 | } |
816 | - if(isset($sugar_config['disable_team_access_check'])) |
|
816 | + if (isset($sugar_config['disable_team_access_check'])) |
|
817 | 817 | { |
818 | 818 | //$sugar_config['disable_team_access_check'] is a runtime configration, |
819 | 819 | //no need to write to config.php |
820 | 820 | unset($sugar_config['disable_team_access_check']); |
821 | 821 | } |
822 | - if(!merge_passwordsetting($sugar_config, $sugar_version)) { |
|
822 | + if (!merge_passwordsetting($sugar_config, $sugar_version)) { |
|
823 | 823 | logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path); |
824 | 824 | $errors[] = 'Could not write config.php!'; |
825 | 825 | } |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | logThis('Set default_theme to Sugar', $path); |
830 | 830 | $sugar_config['default_theme'] = 'Sugar'; |
831 | 831 | |
832 | - if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) { |
|
832 | + if (!write_array_to_file("sugar_config", $sugar_config, "config.php")) { |
|
833 | 833 | logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path); |
834 | 834 | $errors[] = 'Could not write config.php!'; |
835 | 835 | } |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | logThis('Set default_max_tabs to 7', $path); |
838 | 838 | $sugar_config['default_max_tabs'] = '7'; |
839 | 839 | |
840 | - if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) { |
|
840 | + if (!write_array_to_file("sugar_config", $sugar_config, "config.php")) { |
|
841 | 841 | logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path); |
842 | 842 | $errors[] = 'Could not write config.php!'; |
843 | 843 | } |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | logThis('Upgrade the sugar_version', $path); |
851 | 851 | $sugar_config['sugar_version'] = $sugar_version; |
852 | 852 | |
853 | - if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) { |
|
853 | + if (!write_array_to_file("sugar_config", $sugar_config, "config.php")) { |
|
854 | 854 | logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path); |
855 | 855 | $errors[] = 'Could not write config.php!'; |
856 | 856 | } |
@@ -860,10 +860,10 @@ discard block |
||
860 | 860 | |
861 | 861 | /////////////////////////////////////////////////////////////////////////////// |
862 | 862 | //// REGISTER UPGRADE |
863 | - if(empty($errors)) { |
|
863 | + if (empty($errors)) { |
|
864 | 864 | logThis('Registering upgrade with UpgradeHistory', $path); |
865 | - if(!didThisStepRunBefore('commit','upgradeHistory')){ |
|
866 | - set_upgrade_progress('commit','in_progress','upgradeHistory','in_progress'); |
|
865 | + if (!didThisStepRunBefore('commit', 'upgradeHistory')) { |
|
866 | + set_upgrade_progress('commit', 'in_progress', 'upgradeHistory', 'in_progress'); |
|
867 | 867 | $file_action = "copied"; |
868 | 868 | // if error was encountered, script should have died before now |
869 | 869 | $new_upgrade = new UpgradeHistory(); |
@@ -876,26 +876,26 @@ discard block |
||
876 | 876 | $new_upgrade->status = "installed"; |
877 | 877 | $new_upgrade->manifest = (!empty($_SESSION['install_manifest']) ? $_SESSION['install_manifest'] : ''); |
878 | 878 | |
879 | - if($new_upgrade->description == null){ |
|
879 | + if ($new_upgrade->description == null) { |
|
880 | 880 | $new_upgrade->description = "Silent Upgrade was used to upgrade the instance"; |
881 | 881 | } |
882 | - else{ |
|
882 | + else { |
|
883 | 883 | $new_upgrade->description = $new_upgrade->description." Silent Upgrade was used to upgrade the instance."; |
884 | 884 | } |
885 | 885 | $new_upgrade->save(); |
886 | - set_upgrade_progress('commit','in_progress','upgradeHistory','done'); |
|
887 | - set_upgrade_progress('commit','done','commit','done'); |
|
886 | + set_upgrade_progress('commit', 'in_progress', 'upgradeHistory', 'done'); |
|
887 | + set_upgrade_progress('commit', 'done', 'commit', 'done'); |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | |
891 | 891 | //Clean modules from cache |
892 | 892 | $cachedir = sugar_cached('smarty'); |
893 | - if(is_dir($cachedir)){ |
|
893 | + if (is_dir($cachedir)) { |
|
894 | 894 | $allModFiles = array(); |
895 | - $allModFiles = findAllFiles($cachedir,$allModFiles); |
|
896 | - foreach($allModFiles as $file){ |
|
895 | + $allModFiles = findAllFiles($cachedir, $allModFiles); |
|
896 | + foreach ($allModFiles as $file) { |
|
897 | 897 | //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
898 | - if(file_exists($file)){ |
|
898 | + if (file_exists($file)) { |
|
899 | 899 | unlink($file); |
900 | 900 | } |
901 | 901 | } |
@@ -903,12 +903,12 @@ discard block |
||
903 | 903 | //delete cache/modules before rebuilding the relations |
904 | 904 | //Clean modules from cache |
905 | 905 | $cachedir = sugar_cached('modules'); |
906 | - if(is_dir($cachedir)){ |
|
906 | + if (is_dir($cachedir)) { |
|
907 | 907 | $allModFiles = array(); |
908 | - $allModFiles = findAllFiles($cachedir,$allModFiles); |
|
909 | - foreach($allModFiles as $file){ |
|
908 | + $allModFiles = findAllFiles($cachedir, $allModFiles); |
|
909 | + foreach ($allModFiles as $file) { |
|
910 | 910 | //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
911 | - if(file_exists($file)){ |
|
911 | + if (file_exists($file)) { |
|
912 | 912 | unlink($file); |
913 | 913 | } |
914 | 914 | } |
@@ -916,21 +916,21 @@ discard block |
||
916 | 916 | |
917 | 917 | //delete cache/themes |
918 | 918 | $cachedir = sugar_cached('themes'); |
919 | - if(is_dir($cachedir)){ |
|
919 | + if (is_dir($cachedir)) { |
|
920 | 920 | $allModFiles = array(); |
921 | - $allModFiles = findAllFiles($cachedir,$allModFiles); |
|
922 | - foreach($allModFiles as $file){ |
|
921 | + $allModFiles = findAllFiles($cachedir, $allModFiles); |
|
922 | + foreach ($allModFiles as $file) { |
|
923 | 923 | //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
924 | - if(file_exists($file)){ |
|
924 | + if (file_exists($file)) { |
|
925 | 925 | unlink($file); |
926 | 926 | } |
927 | 927 | } |
928 | 928 | } |
929 | 929 | ob_start(); |
930 | - if(!isset($_REQUEST['silent'])){ |
|
930 | + if (!isset($_REQUEST['silent'])) { |
|
931 | 931 | $_REQUEST['silent'] = true; |
932 | 932 | } |
933 | - else if(isset($_REQUEST['silent']) && $_REQUEST['silent'] != true){ |
|
933 | + else if (isset($_REQUEST['silent']) && $_REQUEST['silent'] != true) { |
|
934 | 934 | $_REQUEST['silent'] = true; |
935 | 935 | } |
936 | 936 | |
@@ -942,36 +942,36 @@ discard block |
||
942 | 942 | //fix_dropdown_list(); |
943 | 943 | } |
944 | 944 | |
945 | -set_upgrade_progress('end','in_progress','end','in_progress'); |
|
945 | +set_upgrade_progress('end', 'in_progress', 'end', 'in_progress'); |
|
946 | 946 | /////////////////////////Old Logger settings/////////////////////////////////////// |
947 | 947 | /////////////////////////////////////////////////////////////////////////////// |
948 | 948 | |
949 | -if(function_exists('deleteCache')){ |
|
950 | - set_upgrade_progress('end','in_progress','deleteCache','in_progress'); |
|
949 | +if (function_exists('deleteCache')) { |
|
950 | + set_upgrade_progress('end', 'in_progress', 'deleteCache', 'in_progress'); |
|
951 | 951 | @deleteCache(); |
952 | - set_upgrade_progress('end','in_progress','deleteCache','done'); |
|
952 | + set_upgrade_progress('end', 'in_progress', 'deleteCache', 'done'); |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | /////////////////////////////////////////////////////////////////////////////// |
956 | 956 | //// HANDLE REMINDERS |
957 | -if(empty($errors)) { |
|
957 | +if (empty($errors)) { |
|
958 | 958 | commitHandleReminders($skippedFiles, $path); |
959 | 959 | } |
960 | 960 | |
961 | -if(file_exists(clean_path(getcwd()).'/original451files')){ |
|
961 | +if (file_exists(clean_path(getcwd()).'/original451files')) { |
|
962 | 962 | rmdir_recursive(clean_path(getcwd()).'/original451files'); |
963 | 963 | } |
964 | 964 | |
965 | 965 | require_once('modules/Administration/Administration.php'); |
966 | 966 | $admin = new Administration(); |
967 | -$admin->saveSetting('system','adminwizard',1); |
|
967 | +$admin->saveSetting('system', 'adminwizard', 1); |
|
968 | 968 | |
969 | 969 | |
970 | -if($ce_to_pro_ent) |
|
970 | +if ($ce_to_pro_ent) |
|
971 | 971 | { |
972 | 972 | //check to see if there are any new files that need to be added to systems tab |
973 | 973 | //retrieve old modules list |
974 | - logThis('check to see if new modules exist',$path); |
|
974 | + logThis('check to see if new modules exist', $path); |
|
975 | 975 | $oldModuleList = array(); |
976 | 976 | $newModuleList = array(); |
977 | 977 | include($argv[3].'/include/modules.php'); |
@@ -988,13 +988,13 @@ discard block |
||
988 | 988 | $oldModuleList = $newTB->get_key_array($oldModuleList); |
989 | 989 | |
990 | 990 | //iterate through list and remove commonalities to get new modules |
991 | - foreach ($newModuleList as $remove_mod){ |
|
992 | - if(in_array($remove_mod, $oldModuleList)){ |
|
991 | + foreach ($newModuleList as $remove_mod) { |
|
992 | + if (in_array($remove_mod, $oldModuleList)) { |
|
993 | 993 | unset($newModuleList[$remove_mod]); |
994 | 994 | } |
995 | 995 | } |
996 | 996 | |
997 | - $must_have_modules= array( |
|
997 | + $must_have_modules = array( |
|
998 | 998 | 'Activities'=>'Activities', |
999 | 999 | 'Calendar'=>'Calendar', |
1000 | 1000 | 'Reports' => 'Reports', |
@@ -1004,42 +1004,42 @@ discard block |
||
1004 | 1004 | 'Contracts' => 'Contracts', |
1005 | 1005 | 'KBDocuments' => 'KBDocuments' |
1006 | 1006 | ); |
1007 | - $newModuleList = array_merge($newModuleList,$must_have_modules); |
|
1007 | + $newModuleList = array_merge($newModuleList, $must_have_modules); |
|
1008 | 1008 | |
1009 | 1009 | //new modules list now has left over modules which are new to this install, so lets add them to the system tabs |
1010 | - logThis('new modules to add are '.var_export($newModuleList,true),$path); |
|
1010 | + logThis('new modules to add are '.var_export($newModuleList, true), $path); |
|
1011 | 1011 | |
1012 | 1012 | //grab the existing system tabs |
1013 | 1013 | $tabs = $newTB->get_system_tabs(); |
1014 | 1014 | |
1015 | 1015 | //add the new tabs to the array |
1016 | - foreach($newModuleList as $nm ){ |
|
1016 | + foreach ($newModuleList as $nm) { |
|
1017 | 1017 | $tabs[$nm] = $nm; |
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | //now assign the modules to system tabs |
1021 | 1021 | $newTB->set_system_tabs($tabs); |
1022 | - logThis('module tabs updated',$path); |
|
1022 | + logThis('module tabs updated', $path); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | //Also set the tracker settings if flavor conversion ce->pro or ce->ent |
1026 | -if(isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])){ |
|
1026 | +if (isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])) { |
|
1027 | 1027 | if (version_compare($_SESSION['current_db_version'], $_SESSION['target_db_version'], '=')) |
1028 | 1028 | { |
1029 | 1029 | $_REQUEST['upgradeWizard'] = true; |
1030 | 1030 | ob_start(); |
1031 | 1031 | include('include/Smarty/internals/core.write_file.php'); |
1032 | 1032 | ob_end_clean(); |
1033 | - $db =& DBManagerFactory::getInstance(); |
|
1034 | - if($ce_to_pro_ent){ |
|
1033 | + $db = & DBManagerFactory::getInstance(); |
|
1034 | + if ($ce_to_pro_ent) { |
|
1035 | 1035 | //Also set license information |
1036 | 1036 | $admin = new Administration(); |
1037 | 1037 | $category = 'license'; |
1038 | 1038 | $value = 0; |
1039 | 1039 | $admin->saveSetting($category, 'users', $value); |
1040 | - $key = array('num_lic_oc','key','expire_date'); |
|
1040 | + $key = array('num_lic_oc', 'key', 'expire_date'); |
|
1041 | 1041 | $value = ''; |
1042 | - foreach($key as $k){ |
|
1042 | + foreach ($key as $k) { |
|
1043 | 1043 | $admin->saveSetting($category, $k, $value); |
1044 | 1044 | } |
1045 | 1045 | } |
@@ -1050,8 +1050,8 @@ discard block |
||
1050 | 1050 | ob_end_clean(); |
1051 | 1051 | logThis("**** Potential PHP generated error messages: {$phpErrors}", $path); |
1052 | 1052 | |
1053 | - if(count($errors) > 0) { |
|
1054 | - foreach($errors as $error) { |
|
1053 | + if (count($errors) > 0) { |
|
1054 | + foreach ($errors as $error) { |
|
1055 | 1055 | logThis("****** SilentUpgrade ERROR: {$error}", $path); |
1056 | 1056 | } |
1057 | 1057 | echo "FAILED\n"; |
@@ -1072,18 +1072,18 @@ discard block |
||
1072 | 1072 | { |
1073 | 1073 | $tableDictionaryExtDirs = array('custom/Extension/application/Ext/TableDictionary', 'custom/application/Ext/TableDictionary'); |
1074 | 1074 | |
1075 | - foreach($tableDictionaryExtDirs as $tableDictionaryExt) |
|
1075 | + foreach ($tableDictionaryExtDirs as $tableDictionaryExt) |
|
1076 | 1076 | { |
1077 | 1077 | |
1078 | - if(is_dir($tableDictionaryExt) && is_writable($tableDictionaryExt)){ |
|
1078 | + if (is_dir($tableDictionaryExt) && is_writable($tableDictionaryExt)) { |
|
1079 | 1079 | $dir = dir($tableDictionaryExt); |
1080 | - while(($entry = $dir->read()) !== false) |
|
1080 | + while (($entry = $dir->read()) !== false) |
|
1081 | 1081 | { |
1082 | - $entry = $tableDictionaryExt . '/' . $entry; |
|
1083 | - if(is_file($entry) && preg_match('/\.php$/i', $entry) && is_writeable($entry)) |
|
1082 | + $entry = $tableDictionaryExt.'/'.$entry; |
|
1083 | + if (is_file($entry) && preg_match('/\.php$/i', $entry) && is_writeable($entry)) |
|
1084 | 1084 | { |
1085 | 1085 | |
1086 | - if(function_exists('sugar_fopen')) |
|
1086 | + if (function_exists('sugar_fopen')) |
|
1087 | 1087 | { |
1088 | 1088 | $fp = @sugar_fopen($entry, 'r'); |
1089 | 1089 | } else { |
@@ -1091,16 +1091,16 @@ discard block |
||
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | |
1094 | - if($fp) |
|
1094 | + if ($fp) |
|
1095 | 1095 | { |
1096 | 1096 | $altered = false; |
1097 | 1097 | $contents = ''; |
1098 | 1098 | |
1099 | - while($line = fgets($fp)) |
|
1099 | + while ($line = fgets($fp)) |
|
1100 | 1100 | { |
1101 | - if(preg_match('/\s*include\s*\(\s*[\'|\"](.*?)[\"|\']\s*\)\s*;/', $line, $match)) |
|
1101 | + if (preg_match('/\s*include\s*\(\s*[\'|\"](.*?)[\"|\']\s*\)\s*;/', $line, $match)) |
|
1102 | 1102 | { |
1103 | - if(!file_exists($match[1])) |
|
1103 | + if (!file_exists($match[1])) |
|
1104 | 1104 | { |
1105 | 1105 | $altered = true; |
1106 | 1106 | } else { |
@@ -1115,16 +1115,16 @@ discard block |
||
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | |
1118 | - if($altered) |
|
1118 | + if ($altered) |
|
1119 | 1119 | { |
1120 | - if(function_exists('sugar_fopen')) |
|
1120 | + if (function_exists('sugar_fopen')) |
|
1121 | 1121 | { |
1122 | 1122 | $fp = @sugar_fopen($entry, 'w'); |
1123 | 1123 | } else { |
1124 | 1124 | $fp = fopen($entry, 'w'); |
1125 | 1125 | } |
1126 | 1126 | |
1127 | - if($fp && fwrite($fp, $contents)) |
|
1127 | + if ($fp && fwrite($fp, $contents)) |
|
1128 | 1128 | { |
1129 | 1129 | fclose($fp); |
1130 | 1130 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | //empty function getJSPath().. there is some dependency in meta upgrade |
46 | 46 | |
47 | -function getJSPath($file=''){ |
|
47 | +function getJSPath($file = '') { |
|
48 | 48 | //nothing here fake function |
49 | 49 | } |
50 | 50 | ?> |
51 | 51 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -45,25 +45,25 @@ discard block |
||
45 | 45 | * Reserved. Contributor(s): ______________________________________.. |
46 | 46 | * *******************************************************************************/ |
47 | 47 | |
48 | -if(ob_get_level() < 1) |
|
48 | +if (ob_get_level() < 1) |
|
49 | 49 | ob_start(); |
50 | 50 | ob_implicit_flush(1); |
51 | 51 | |
52 | 52 | // load the generated persistence file if found |
53 | 53 | $persistence = array(); |
54 | -if(file_exists($persist = sugar_cached('/modules/UpgradeWizard/_persistence.php'))) { |
|
54 | +if (file_exists($persist = sugar_cached('/modules/UpgradeWizard/_persistence.php'))) { |
|
55 | 55 | require_once $persist; |
56 | 56 | } |
57 | 57 | require_once('modules/UpgradeWizard/uw_utils.php'); |
58 | 58 | |
59 | -switch($_REQUEST['systemCheckStep']) { |
|
59 | +switch ($_REQUEST['systemCheckStep']) { |
|
60 | 60 | case 'find_all_files': |
61 | 61 | ob_end_flush(); |
62 | 62 | $persistence['files_to_check'] = getFilesForPermsCheck(); |
63 | 63 | break; |
64 | 64 | |
65 | 65 | case 'check_found_files': |
66 | - if(empty($persistence['files_to_check'])) { |
|
66 | + if (empty($persistence['files_to_check'])) { |
|
67 | 67 | logThis('*** ERROR: could not find persistent array of files to check'); |
68 | 68 | echo $mod_strings['ERR_UW_NO_FILES']; |
69 | 69 | } else { |
@@ -42,40 +42,40 @@ discard block |
||
42 | 42 | //// php.exe -f silentUpgrade.php [Path to Upgrade Package zip] [Path to Log file] [Path to Instance] |
43 | 43 | //// See below the Usage for more details. |
44 | 44 | ///////////////////////////////////////////////////////////////////////////////////////// |
45 | -ini_set('memory_limit',-1); |
|
45 | +ini_set('memory_limit', -1); |
|
46 | 46 | /////////////////////////////////////////////////////////////////////////////// |
47 | 47 | //// UTILITIES THAT MUST BE LOCAL :( |
48 | 48 | //Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if |
49 | 49 | //no found then adds default_permissions to the config file. |
50 | - function checkConfigForPermissions(){ |
|
51 | - if(file_exists(getcwd().'/config.php')){ |
|
50 | + function checkConfigForPermissions() { |
|
51 | + if (file_exists(getcwd().'/config.php')) { |
|
52 | 52 | require(getcwd().'/config.php'); |
53 | 53 | } |
54 | 54 | global $sugar_config; |
55 | - if(!isset($sugar_config['default_permissions'])){ |
|
56 | - $sugar_config['default_permissions'] = array ( |
|
55 | + if (!isset($sugar_config['default_permissions'])) { |
|
56 | + $sugar_config['default_permissions'] = array( |
|
57 | 57 | 'dir_mode' => 02770, |
58 | 58 | 'file_mode' => 0660, |
59 | 59 | 'user' => '', |
60 | 60 | 'group' => '', |
61 | 61 | ); |
62 | 62 | ksort($sugar_config); |
63 | - if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) { |
|
63 | + if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) { |
|
64 | 64 | //writing to the file |
65 | 65 | } |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -function checkLoggerSettings(){ |
|
70 | - if(file_exists(getcwd().'/config.php')){ |
|
69 | +function checkLoggerSettings() { |
|
70 | + if (file_exists(getcwd().'/config.php')) { |
|
71 | 71 | require(getcwd().'/config.php'); |
72 | 72 | } |
73 | 73 | global $sugar_config; |
74 | - if(!isset($sugar_config['logger'])){ |
|
75 | - $sugar_config['logger'] =array ( |
|
74 | + if (!isset($sugar_config['logger'])) { |
|
75 | + $sugar_config['logger'] = array( |
|
76 | 76 | 'level'=>'fatal', |
77 | 77 | 'file' => |
78 | - array ( |
|
78 | + array( |
|
79 | 79 | 'ext' => '.log', |
80 | 80 | 'name' => 'sugarcrm', |
81 | 81 | 'dateFormat' => '%c', |
@@ -85,23 +85,23 @@ discard block |
||
85 | 85 | ), |
86 | 86 | ); |
87 | 87 | ksort($sugar_config); |
88 | - if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) { |
|
88 | + if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) { |
|
89 | 89 | //writing to the file |
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | -function checkResourceSettings(){ |
|
95 | - if(file_exists(getcwd().'/config.php')){ |
|
94 | +function checkResourceSettings() { |
|
95 | + if (file_exists(getcwd().'/config.php')) { |
|
96 | 96 | require(getcwd().'/config.php'); |
97 | 97 | } |
98 | 98 | global $sugar_config; |
99 | - if(!isset($sugar_config['resource_management'])){ |
|
99 | + if (!isset($sugar_config['resource_management'])) { |
|
100 | 100 | $sugar_config['resource_management'] = |
101 | - array ( |
|
101 | + array( |
|
102 | 102 | 'special_query_limit' => 50000, |
103 | 103 | 'special_query_modules' => |
104 | - array ( |
|
104 | + array( |
|
105 | 105 | 0 => 'Reports', |
106 | 106 | 1 => 'Export', |
107 | 107 | 2 => 'Import', |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | 'default_limit' => 1000, |
112 | 112 | ); |
113 | 113 | ksort($sugar_config); |
114 | - if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) { |
|
114 | + if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) { |
|
115 | 115 | //writing to the file |
116 | 116 | } |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | 120 | |
121 | -function verifyArguments($argv,$usage_regular){ |
|
121 | +function verifyArguments($argv, $usage_regular) { |
|
122 | 122 | $upgradeType = ''; |
123 | 123 | $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir. |
124 | - if(isset($argv[3])) { |
|
125 | - if(is_dir($argv[3])) { |
|
124 | + if (isset($argv[3])) { |
|
125 | + if (is_dir($argv[3])) { |
|
126 | 126 | $cwd = $argv[3]; |
127 | 127 | chdir($cwd); |
128 | 128 | } else { |
@@ -133,18 +133,18 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | //check if this is an instance |
136 | - if(is_file("{$cwd}/include/entryPoint.php")) { |
|
136 | + if (is_file("{$cwd}/include/entryPoint.php")) { |
|
137 | 137 | //this should be a regular sugar install |
138 | 138 | $upgradeType = constant('SUGARCRM_INSTALL'); |
139 | 139 | //check if this is a valid zip file |
140 | - if(!is_file($argv[1])) { // valid zip? |
|
140 | + if (!is_file($argv[1])) { // valid zip? |
|
141 | 141 | echo "*******************************************************************************\n"; |
142 | 142 | echo "*** ERROR: First argument must be a full path to the patch file. Got [ {$argv[1]} ].\n"; |
143 | 143 | echo $usage_regular; |
144 | 144 | echo "FAILURE\n"; |
145 | 145 | exit(1); |
146 | 146 | } |
147 | - if(count($argv) < 5) { |
|
147 | + if (count($argv) < 5) { |
|
148 | 148 | echo "*******************************************************************************\n"; |
149 | 149 | echo "*** ERROR: Missing required parameters. Received ".count($argv)." argument(s), require 5.\n"; |
150 | 150 | echo $usage_regular; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | exit(1); |
160 | 160 | } |
161 | 161 | |
162 | - if(isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')){ |
|
162 | + if (isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')) { |
|
163 | 163 | require_once($argv[7].'SugarTemplateUtilties.php'); |
164 | 164 | } |
165 | 165 | |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | //End of #52872 |
186 | 186 | |
187 | 187 | // only run from command line |
188 | -if(isset($_SERVER['HTTP_USER_AGENT'])) { |
|
189 | - fwrite(STDERR,'This utility may only be run from the command line or command prompt.'); |
|
188 | +if (isset($_SERVER['HTTP_USER_AGENT'])) { |
|
189 | + fwrite(STDERR, 'This utility may only be run from the command line or command prompt.'); |
|
190 | 190 | exit(1); |
191 | 191 | } |
192 | 192 | //Clean_string cleans out any file passed in as a parameter |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | /////////////////////////////////////////////////////////////////////////////// |
197 | 197 | //// USAGE |
198 | -$usage_regular =<<<eoq2 |
|
198 | +$usage_regular = <<<eoq2 |
|
199 | 199 | Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance] [admin-user] |
200 | 200 | |
201 | 201 | On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | /////////////////////////////////////////////////////////////////////////////// |
219 | 219 | //// STANDARD REQUIRED SUGAR INCLUDES AND PRESETS |
220 | -if(!defined('sugarEntry')) define('sugarEntry', true); |
|
220 | +if (!defined('sugarEntry')) define('sugarEntry', true); |
|
221 | 221 | |
222 | 222 | $_SESSION = array(); |
223 | 223 | $_SESSION['schema_change'] = 'sugar'; // we force-run all SQL |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | global $cwd; |
235 | 235 | $cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir. |
236 | 236 | |
237 | -$upgradeType = verifyArguments($argv,$usage_regular); |
|
237 | +$upgradeType = verifyArguments($argv, $usage_regular); |
|
238 | 238 | |
239 | -$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log |
|
240 | -$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); |
|
239 | +$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log |
|
240 | +$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); |
|
241 | 241 | |
242 | 242 | require_once('include/entryPoint.php'); |
243 | 243 | require_once('modules/UpgradeWizard/uw_utils.php'); |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | $errors = array(); |
250 | 250 | |
251 | 251 | require('config.php'); |
252 | - if(isset($argv[3])) { |
|
253 | - if(is_dir($argv[3])) { |
|
252 | + if (isset($argv[3])) { |
|
253 | + if (is_dir($argv[3])) { |
|
254 | 254 | $cwd = $argv[3]; |
255 | 255 | chdir($cwd); |
256 | 256 | } |
@@ -261,36 +261,36 @@ discard block |
||
261 | 261 | global $sugar_config; |
262 | 262 | $configOptions = $sugar_config['dbconfig']; |
263 | 263 | |
264 | - $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM'); |
|
265 | - $patchName = basename($argv[1]); |
|
266 | - $zip_from_dir = substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip") |
|
267 | - $path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log |
|
268 | - $db = &DBManagerFactory::getInstance(); |
|
269 | - $UWstrings = return_module_language('en_us', 'UpgradeWizard', true); |
|
270 | - $adminStrings = return_module_language('en_us', 'Administration', true); |
|
264 | + $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM'); |
|
265 | + $patchName = basename($argv[1]); |
|
266 | + $zip_from_dir = substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip") |
|
267 | + $path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log |
|
268 | + $db = &DBManagerFactory::getInstance(); |
|
269 | + $UWstrings = return_module_language('en_us', 'UpgradeWizard', true); |
|
270 | + $adminStrings = return_module_language('en_us', 'Administration', true); |
|
271 | 271 | $app_list_strings = return_app_list_strings_language('en_us'); |
272 | - $mod_strings = array_merge($adminStrings, $UWstrings); |
|
273 | - $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); |
|
272 | + $mod_strings = array_merge($adminStrings, $UWstrings); |
|
273 | + $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); |
|
274 | 274 | global $unzip_dir; |
275 | 275 | $license_accepted = false; |
276 | - if(isset($argv[5]) && (strtolower($argv[5])=='yes' || strtolower($argv[5])=='y')){ |
|
276 | + if (isset($argv[5]) && (strtolower($argv[5]) == 'yes' || strtolower($argv[5]) == 'y')) { |
|
277 | 277 | $license_accepted = true; |
278 | 278 | } |
279 | 279 | ////////////////////////////////////////////////////////////////////////////// |
280 | 280 | //Adding admin user to the silent upgrade |
281 | 281 | |
282 | 282 | $current_user = new User(); |
283 | - if(isset($argv[4])) { |
|
283 | + if (isset($argv[4])) { |
|
284 | 284 | //if being used for internal upgrades avoid admin user verification |
285 | 285 | $user_name = $argv[4]; |
286 | - $q = "select id from users where user_name = '" . $user_name . "' and is_admin=1"; |
|
286 | + $q = "select id from users where user_name = '".$user_name."' and is_admin=1"; |
|
287 | 287 | $result = $GLOBALS['db']->query($q, false); |
288 | 288 | $logged_user = $GLOBALS['db']->fetchByAssoc($result); |
289 | - if(isset($logged_user['id']) && $logged_user['id'] != null){ |
|
289 | + if (isset($logged_user['id']) && $logged_user['id'] != null) { |
|
290 | 290 | //do nothing |
291 | 291 | $current_user->retrieve($logged_user['id']); |
292 | 292 | } |
293 | - else{ |
|
293 | + else { |
|
294 | 294 | echo "Not an admin user in users table. Please provide an admin user\n"; |
295 | 295 | exit(1); |
296 | 296 | } |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | $_SESSION['zip_from_dir'] = $zip_from_dir; |
315 | 315 | |
316 | 316 | mkdir_recursive($unzip_dir); |
317 | -if(!is_dir($unzip_dir)) { |
|
318 | - fwrite(STDERR,"\n{$unzip_dir} is not an available directory\nFAILURE\n"); |
|
317 | +if (!is_dir($unzip_dir)) { |
|
318 | + fwrite(STDERR, "\n{$unzip_dir} is not an available directory\nFAILURE\n"); |
|
319 | 319 | exit(1); |
320 | 320 | } |
321 | 321 | unzip($argv[1], $unzip_dir); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | /////////////////////////////////////////////////////////////////////////////// |
326 | 326 | |
327 | 327 | |
328 | -if(function_exists('set_upgrade_vars')){ |
|
328 | +if (function_exists('set_upgrade_vars')) { |
|
329 | 329 | set_upgrade_vars(); |
330 | 330 | } |
331 | 331 | |
@@ -349,18 +349,18 @@ discard block |
||
349 | 349 | upgrade_custom_relationships(); |
350 | 350 | |
351 | 351 | logThis('Upgrading user preferences start .', $path); |
352 | -if(function_exists('upgradeUserPreferences')){ |
|
352 | +if (function_exists('upgradeUserPreferences')) { |
|
353 | 353 | upgradeUserPreferences(); |
354 | 354 | } |
355 | 355 | logThis('Upgrading user preferences finish .', $path); |
356 | 356 | |
357 | 357 | // clear out the theme cache |
358 | -if(is_dir($GLOBALS['sugar_config']['cache_dir'].'themes')){ |
|
358 | +if (is_dir($GLOBALS['sugar_config']['cache_dir'].'themes')) { |
|
359 | 359 | $allModFiles = array(); |
360 | - $allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'themes',$allModFiles); |
|
361 | - foreach($allModFiles as $file){ |
|
360 | + $allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'themes', $allModFiles); |
|
361 | + foreach ($allModFiles as $file) { |
|
362 | 362 | //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
363 | - if(file_exists($file)){ |
|
363 | + if (file_exists($file)) { |
|
364 | 364 | unlink($file); |
365 | 365 | } |
366 | 366 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | require_once('jssource/minify.php'); |
373 | 373 | |
374 | 374 | //Add the cache cleaning here. |
375 | -if(function_exists('deleteCache')) |
|
375 | +if (function_exists('deleteCache')) |
|
376 | 376 | { |
377 | 377 | logThis('Call deleteCache', $path); |
378 | 378 | @deleteCache(); |
@@ -411,35 +411,35 @@ discard block |
||
411 | 411 | $rac->clearVardefs(); |
412 | 412 | $rac->rebuildExtensions(); |
413 | 413 | //bug: 44431 - defensive check to ensure the method exists since upgrades to 6.2.0 may not have this method define yet. |
414 | -if(method_exists($rac, 'clearExternalAPICache')) |
|
414 | +if (method_exists($rac, 'clearExternalAPICache')) |
|
415 | 415 | { |
416 | 416 | $rac->clearExternalAPICache(); |
417 | 417 | } |
418 | 418 | |
419 | 419 | $repairedTables = array(); |
420 | 420 | foreach ($beanFiles as $bean => $file) { |
421 | - if(file_exists($file)){ |
|
421 | + if (file_exists($file)) { |
|
422 | 422 | unset($GLOBALS['dictionary'][$bean]); |
423 | 423 | require_once($file); |
424 | - $focus = new $bean (); |
|
425 | - if(empty($focus->table_name) || isset($repairedTables[$focus->table_name])) { |
|
424 | + $focus = new $bean(); |
|
425 | + if (empty($focus->table_name) || isset($repairedTables[$focus->table_name])) { |
|
426 | 426 | continue; |
427 | 427 | } |
428 | 428 | |
429 | 429 | if (($focus instanceOf SugarBean)) { |
430 | - if(!isset($repairedTables[$focus->table_name])) |
|
430 | + if (!isset($repairedTables[$focus->table_name])) |
|
431 | 431 | { |
432 | 432 | $sql = $GLOBALS['db']->repairTable($focus, true); |
433 | - if(trim($sql) != '') |
|
433 | + if (trim($sql) != '') |
|
434 | 434 | { |
435 | - logThis('Running sql:' . $sql, $path); |
|
435 | + logThis('Running sql:'.$sql, $path); |
|
436 | 436 | } |
437 | 437 | $repairedTables[$focus->table_name] = true; |
438 | 438 | } |
439 | 439 | |
440 | 440 | //Check to see if we need to create the audit table |
441 | - if($focus->is_AuditEnabled() && !$focus->db->tableExists($focus->get_audit_table_name())){ |
|
442 | - logThis('Creating audit table:' . $focus->get_audit_table_name(), $path); |
|
441 | + if ($focus->is_AuditEnabled() && !$focus->db->tableExists($focus->get_audit_table_name())) { |
|
442 | + logThis('Creating audit table:'.$focus->get_audit_table_name(), $path); |
|
443 | 443 | $focus->create_audit_table(); |
444 | 444 | } |
445 | 445 | } |
@@ -451,14 +451,14 @@ discard block |
||
451 | 451 | foreach ($dictionary as $meta) { |
452 | 452 | $tablename = $meta['table']; |
453 | 453 | |
454 | - if(isset($repairedTables[$tablename])) { |
|
454 | + if (isset($repairedTables[$tablename])) { |
|
455 | 455 | continue; |
456 | 456 | } |
457 | 457 | |
458 | 458 | $fielddefs = $meta['fields']; |
459 | 459 | $indices = $meta['indices']; |
460 | 460 | $sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true); |
461 | - if(!empty($sql)) { |
|
461 | + if (!empty($sql)) { |
|
462 | 462 | logThis($sql, $path); |
463 | 463 | $repairedTables[$tablename] = true; |
464 | 464 | } |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | logThis('End rebuild relationships.', $path); |
473 | 473 | |
474 | 474 | include("$unzip_dir/manifest.php"); |
475 | -$ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt' || $manifest['name'] == 'SugarCE to SugarCorp' || $manifest['name'] == 'SugarCE to SugarUlt'); |
|
475 | +$ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt' || $manifest['name'] == 'SugarCE to SugarCorp' || $manifest['name'] == 'SugarCE to SugarUlt'); |
|
476 | 476 | $sugar_version = getSilentUpgradeVar('origVersion'); |
477 | 477 | if (!$sugar_version) |
478 | 478 | { |
@@ -481,15 +481,15 @@ discard block |
||
481 | 481 | } |
482 | 482 | |
483 | 483 | |
484 | -if($ce_to_pro_ent) { |
|
484 | +if ($ce_to_pro_ent) { |
|
485 | 485 | //add the global team if it does not exist |
486 | 486 | $globalteam = new Team(); |
487 | 487 | $globalteam->retrieve('1'); |
488 | 488 | require_once($unzip_dir.'/'.$zip_from_dir.'/modules/Administration/language/en_us.lang.php'); |
489 | - if(isset($globalteam->name)){ |
|
489 | + if (isset($globalteam->name)) { |
|
490 | 490 | echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>'; |
491 | 491 | logThis(" Finish Building Global Team", $path); |
492 | - }else{ |
|
492 | + } else { |
|
493 | 493 | $globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team); |
494 | 494 | } |
495 | 495 | |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | include('modules/Administration/upgradeTeams.php'); |
507 | 507 | logThis(" Finish modules/Administration/upgradeTeams.php", $path); |
508 | 508 | |
509 | - if(check_FTS()){ |
|
509 | + if (check_FTS()) { |
|
510 | 510 | $GLOBALS['db']->full_text_indexing_setup(); |
511 | 511 | } |
512 | 512 | } |
@@ -523,12 +523,12 @@ discard block |
||
523 | 523 | |
524 | 524 | |
525 | 525 | //Unlink files that have been removed |
526 | -if(function_exists('unlinkUpgradeFiles')) |
|
526 | +if (function_exists('unlinkUpgradeFiles')) |
|
527 | 527 | { |
528 | 528 | unlinkUpgradeFiles($sugar_version); |
529 | 529 | } |
530 | 530 | |
531 | -if(function_exists('rebuildSprites') && function_exists('imagecreatetruecolor')) |
|
531 | +if (function_exists('rebuildSprites') && function_exists('imagecreatetruecolor')) |
|
532 | 532 | { |
533 | 533 | rebuildSprites(true); |
534 | 534 | } |
@@ -541,8 +541,8 @@ discard block |
||
541 | 541 | |
542 | 542 | /////////////////////////////////////////////////////////////////////////////// |
543 | 543 | //// TAKE OUT TRASH |
544 | -if(empty($errors)) { |
|
545 | - set_upgrade_progress('end','in_progress','unlinkingfiles','in_progress'); |
|
544 | +if (empty($errors)) { |
|
545 | + set_upgrade_progress('end', 'in_progress', 'unlinkingfiles', 'in_progress'); |
|
546 | 546 | logThis('Taking out the trash, unlinking temp files.', $path); |
547 | 547 | unlinkUWTempFiles(); |
548 | 548 | removeSilentUpgradeVarsCache(); |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | ob_end_clean(); |
557 | 557 | logThis("**** Potential PHP generated error messages: {$phpErrors}", $path); |
558 | 558 | |
559 | -if(count($errors) > 0) { |
|
560 | - foreach($errors as $error) { |
|
559 | +if (count($errors) > 0) { |
|
560 | + foreach ($errors as $error) { |
|
561 | 561 | logThis("****** SilentUpgrade ERROR: {$error}", $path); |
562 | 562 | } |
563 | 563 | echo "FAILED\n"; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -45,19 +45,19 @@ discard block |
||
45 | 45 | * Reserved. Contributor(s): ______________________________________.. |
46 | 46 | * *******************************************************************************/ |
47 | 47 | |
48 | -if(ob_get_level() < 1) |
|
48 | +if (ob_get_level() < 1) |
|
49 | 49 | ob_start(); |
50 | 50 | ob_implicit_flush(1); |
51 | 51 | |
52 | 52 | // load the generated persistence file if found |
53 | 53 | $persistence = array(); |
54 | -if(file_exists($persist = sugar_cached('/modules/UpgradeWizard/_persistence.php'))) { |
|
54 | +if (file_exists($persist = sugar_cached('/modules/UpgradeWizard/_persistence.php'))) { |
|
55 | 55 | require_once $persist; |
56 | 56 | } |
57 | 57 | require_once('modules/UpgradeWizard/uw_utils.php'); |
58 | 58 | require_once('include/utils/zip_utils.php'); |
59 | 59 | |
60 | -switch($_REQUEST['preflightStep']) { |
|
60 | +switch ($_REQUEST['preflightStep']) { |
|
61 | 61 | case 'find_upgrade_files': |
62 | 62 | logThis('preflightJson finding upgrade files'); |
63 | 63 | ob_end_flush(); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -50,13 +50,13 @@ discard block |
||
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){ |
|
53 | + if (isset($file_name['jsonObject']) && $file_name['jsonObject'] != null) { |
|
54 | 54 | $file_name = $file_name['jsonObject']; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $filesize = ''; |
58 | -if(file_exists($file_name)){ |
|
59 | - $filesize =filesize($file_name); |
|
58 | +if (file_exists($file_name)) { |
|
59 | + $filesize = filesize($file_name); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | //get the file size defined in php.ini |
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 | -if($filesize != null){ |
|
76 | - if(($filesize > return_bytes(ini_get("upload_max_filesize"))) || ($filesize > return_bytes(ini_get("post_max_size")))){ |
|
77 | - $response=$filesize; |
|
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 | 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 | 79 | } |
80 | 80 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | */ |
74 | 74 | |
75 | - $_SESSION['totalUpgradeTime'] = $_SESSION['totalUpgradeTime']+$_REQUEST['upgradeStepTime']; |
|
75 | + $_SESSION['totalUpgradeTime'] = $_SESSION['totalUpgradeTime'] + $_REQUEST['upgradeStepTime']; |
|
76 | 76 | $response = $_SESSION['totalUpgradeTime']; |
77 | 77 | |
78 | 78 | $GLOBALS['log']->fatal('TOTAL TIME .....'.$_SESSION['totalUpgradeTime']); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -77,26 +77,26 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param mixed $files |
79 | 79 | */ |
80 | -public function processFilesToRemove($files=array()) |
|
80 | +public function processFilesToRemove($files = array()) |
|
81 | 81 | { |
82 | - if(empty($files) || !is_array($files)) |
|
82 | + if (empty($files) || !is_array($files)) |
|
83 | 83 | { |
84 | 84 | return; |
85 | 85 | } |
86 | 86 | |
87 | 87 | require_once('include/dir_inc.php'); |
88 | 88 | |
89 | - if(!file_exists('custom/backup')) |
|
89 | + if (!file_exists('custom/backup')) |
|
90 | 90 | { |
91 | 91 | mkdir_recursive('custom/backup'); |
92 | 92 | } |
93 | 93 | |
94 | - foreach($files as $file) |
|
94 | + foreach ($files as $file) |
|
95 | 95 | { |
96 | - if(file_exists($file)) |
|
96 | + if (file_exists($file)) |
|
97 | 97 | { |
98 | 98 | $this->backup($file); |
99 | - if(is_dir($file)) |
|
99 | + if (is_dir($file)) |
|
100 | 100 | { |
101 | 101 | rmdir_recursive($file); |
102 | 102 | } else { |
@@ -118,16 +118,16 @@ discard block |
||
118 | 118 | $basename = basename($file); |
119 | 119 | $basepath = str_replace($basename, '', $file); |
120 | 120 | |
121 | - if(!empty($basepath) && !file_exists('custom/backup/' . $basepath)) |
|
121 | + if (!empty($basepath) && !file_exists('custom/backup/'.$basepath)) |
|
122 | 122 | { |
123 | - mkdir_recursive('custom/backup/' . $basepath); |
|
123 | + mkdir_recursive('custom/backup/'.$basepath); |
|
124 | 124 | } |
125 | 125 | |
126 | - if(is_dir($file)) |
|
126 | + if (is_dir($file)) |
|
127 | 127 | { |
128 | - copy_recursive($file, 'custom/backup/' . $file); |
|
128 | + copy_recursive($file, 'custom/backup/'.$file); |
|
129 | 129 | } else { |
130 | - copy($file, 'custom/backup/' . $file); |
|
130 | + copy($file, 'custom/backup/'.$file); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 |
@@ -34,25 +34,25 @@ discard block |
||
34 | 34 | * "Powered by SugarCRM". |
35 | 35 | ********************************************************************************/ |
36 | 36 | |
37 | -function build_argument_string($arguments=array()) { |
|
38 | - if(!is_array($arguments)) { |
|
37 | +function build_argument_string($arguments = array()) { |
|
38 | + if (!is_array($arguments)) { |
|
39 | 39 | return ''; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $argument_string = ''; |
43 | 43 | $count = 0; |
44 | - foreach($arguments as $arg) { |
|
45 | - if($count != 0) |
|
44 | + foreach ($arguments as $arg) { |
|
45 | + if ($count != 0) |
|
46 | 46 | { |
47 | 47 | //If current directory or parent directory is specified, substitute with full path |
48 | - if($arg == '.') |
|
48 | + if ($arg == '.') |
|
49 | 49 | { |
50 | 50 | $arg = getcwd(); |
51 | 51 | } else if ($arg == '..') { |
52 | 52 | $dir = getcwd(); |
53 | 53 | $arg = substr($dir, 0, strrpos($dir, DIRECTORY_SEPARATOR)); |
54 | 54 | } |
55 | - $argument_string .= ' ' . escapeshellarg($arg); |
|
55 | + $argument_string .= ' '.escapeshellarg($arg); |
|
56 | 56 | } |
57 | 57 | $count++; |
58 | 58 | } |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | |
70 | 70 | $php_path = ''; |
71 | 71 | $run_dce_upgrade = false; |
72 | -if(isset($argv[3]) && is_dir($argv[3]) && file_exists($argv[3]."/ini_setup.php")) { |
|
72 | +if (isset($argv[3]) && is_dir($argv[3]) && file_exists($argv[3]."/ini_setup.php")) { |
|
73 | 73 | //this is a dce call, set the dce flag |
74 | 74 | chdir($argv[3]); |
75 | 75 | $run_dce_upgrade = true; |
76 | 76 | //set the php path if found |
77 | - if(is_file($argv[7].'dce_config.php')){ |
|
77 | + if (is_file($argv[7].'dce_config.php')) { |
|
78 | 78 | include($argv[7].'dce_config.php'); |
79 | 79 | $php_path = $dce_config['client_php_path'].'/'; |
80 | 80 | } |
@@ -82,34 +82,34 @@ discard block |
||
82 | 82 | |
83 | 83 | $php_file = $argv[0]; |
84 | 84 | $p_info = pathinfo($php_file); |
85 | -$php_dir = (isset($p_info['dirname']) && $p_info['dirname'] != '.') ? $p_info['dirname'] . '/' : ''; |
|
85 | +$php_dir = (isset($p_info['dirname']) && $p_info['dirname'] != '.') ? $p_info['dirname'].'/' : ''; |
|
86 | 86 | |
87 | -$step1 = $php_path."php -f {$php_dir}silentUpgrade_step1.php " . build_argument_string($argv); |
|
87 | +$step1 = $php_path."php -f {$php_dir}silentUpgrade_step1.php ".build_argument_string($argv); |
|
88 | 88 | passthru($step1, $output); |
89 | -if($output != 0) { |
|
89 | +if ($output != 0) { |
|
90 | 90 | echo "*************** step1 failed ***************: $output\n"; |
91 | 91 | } |
92 | 92 | $has_error = $output == 0 ? false : true; |
93 | 93 | |
94 | -if(!$has_error) { |
|
95 | - if($run_dce_upgrade) { |
|
96 | - $step2 = $php_path."php -f {$php_dir}silentUpgrade_dce_step1.php " . build_argument_string($argv); |
|
94 | +if (!$has_error) { |
|
95 | + if ($run_dce_upgrade) { |
|
96 | + $step2 = $php_path."php -f {$php_dir}silentUpgrade_dce_step1.php ".build_argument_string($argv); |
|
97 | 97 | passthru($step2, $output); |
98 | 98 | } else { |
99 | - $step2 = "php -f {$php_dir}silentUpgrade_step2.php " . build_argument_string($argv); |
|
99 | + $step2 = "php -f {$php_dir}silentUpgrade_step2.php ".build_argument_string($argv); |
|
100 | 100 | passthru($step2, $output); |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | -if($run_dce_upgrade) { |
|
104 | +if ($run_dce_upgrade) { |
|
105 | 105 | $has_error = $output == 0 ? false : true; |
106 | - if(!$has_error) { |
|
107 | - $step3 = $php_path."php -f {$php_dir}silentUpgrade_dce_step2.php " . build_argument_string($argv); |
|
106 | + if (!$has_error) { |
|
107 | + $step3 = $php_path."php -f {$php_dir}silentUpgrade_dce_step2.php ".build_argument_string($argv); |
|
108 | 108 | passthru($step3, $output); |
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | -if($output != 0) { |
|
112 | +if ($output != 0) { |
|
113 | 113 | echo "*************** silentupgrade failed ***************: $output\n"; |
114 | 114 | } |
115 | 115 | exit($output); |