forked from salesagility/SuiteCRM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperformSetup.php
executable file
·580 lines (485 loc) · 20.2 KB
/
performSetup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
* Copyright (C) 2011 - 2014 Salesagility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
********************************************************************************/
// This file will load the configuration settings from session data,
// write to the config file, and execute any necessary database steps.
$GLOBALS['installing'] = true;
if( !isset( $install_script ) || !$install_script ){
die($mod_strings['ERR_NO_DIRECT_SCRIPT']);
}
ini_set("output_buffering","0");
set_time_limit(3600);
// flush after each output so the user can see the progress in real-time
ob_implicit_flush();
require_once('install/install_utils.php');
require_once('modules/TableDictionary.php');
$trackerManager = TrackerManager::getInstance();
$trackerManager->pause();
$cache_dir = sugar_cached("");
$line_entry_format = "     <b>";
$line_exit_format = "...   </b>";
$rel_dictionary = $dictionary; // sourced by modules/TableDictionary.php
$render_table_close = "";
$render_table_open = "";
$setup_db_admin_password = $_SESSION['setup_db_admin_password'];
$setup_db_admin_user_name = $_SESSION['setup_db_admin_user_name'];
$setup_db_create_database = $_SESSION['setup_db_create_database'];
$setup_db_create_sugarsales_user = $_SESSION['setup_db_create_sugarsales_user'];
$setup_db_database_name = $_SESSION['setup_db_database_name'];
$setup_db_drop_tables = $_SESSION['setup_db_drop_tables'];
$setup_db_host_instance = $_SESSION['setup_db_host_instance'];
$setup_db_port_num = $_SESSION['setup_db_port_num'];
$setup_db_host_name = $_SESSION['setup_db_host_name'];
$demoData = $_SESSION['demoData'];
$setup_db_sugarsales_password = $_SESSION['setup_db_sugarsales_password'];
$setup_db_sugarsales_user = $_SESSION['setup_db_sugarsales_user'];
$setup_site_admin_user_name = $_SESSION['setup_site_admin_user_name'];
$setup_site_admin_password = $_SESSION['setup_site_admin_password'];
$setup_site_guid = (isset($_SESSION['setup_site_specify_guid']) && $_SESSION['setup_site_specify_guid'] != '') ? $_SESSION['setup_site_guid'] : '';
$setup_site_url = $_SESSION['setup_site_url'];
$parsed_url = parse_url($setup_site_url);
$setup_site_host_name = $parsed_url['host'];
$setup_site_log_dir = isset($_SESSION['setup_site_custom_log_dir']) ? $_SESSION['setup_site_log_dir'] : '.';
$setup_site_log_file = 'suitecrm.log'; // may be an option later
$setup_site_session_path = isset($_SESSION['setup_site_custom_session_path']) ? $_SESSION['setup_site_session_path'] : '';
$setup_site_log_level ='fatal';
sugar_cache_clear('TeamSetsCache');
if ( file_exists($cache_dir .'modules/Teams/TeamSetCache.php') ) {
unlink($cache_dir.'modules/Teams/TeamSetCache.php');
}
sugar_cache_clear('TeamSetsMD5Cache');
if ( file_exists($cache_dir.'modules/Teams/TeamSetMD5Cache.php') ) {
unlink($cache_dir.'modules/Teams/TeamSetMD5Cache.php');
}
$langHeader = get_language_header();
$out =<<<EOQ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html {$langHeader}>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>{$mod_strings['LBL_WIZARD_TITLE']} {$mod_strings['LBL_PERFORM_TITLE']}</title>
<link REL="SHORTCUT ICON" HREF="$icon">
<link rel="stylesheet" href="$css" type="text/css" />
<script type="text/javascript" src="$common"></script>
</head>
<body onload="javascript:document.getElementById('button_next2').focus();">
<table cellspacing="0" cellpadding="0" border="0" align="center" class="shell">
<tr><td colspan="2" id="help"><a href="{$help_url}" target='_blank'>{$mod_strings['LBL_HELP']} </a></td></tr>
<tr>
<th width="500">
<p>
<img src="{$sugar_md}" alt="SuiteCRM" border="0">
</p>
{$mod_strings['LBL_PERFORM_TITLE']}</th>
<th width="200" style="text-align: right;"></th>
</tr>
<tr>
<td colspan="2">
EOQ;
echo $out;
installLog("calling handleSugarConfig()");
$bottle = handleSugarConfig();
//installLog("calling handleLog4Php()");
//handleLog4Php();
$server_software = $_SERVER["SERVER_SOFTWARE"];
if(strpos($server_software,'Microsoft-IIS') !== false)
{
installLog("calling handleWebConfig()");
handleWebConfig();
} else {
installLog("calling handleHtaccess()");
handleHtaccess();
}
///////////////////////////////////////////////////////////////////////////////
//// START TABLE STUFF
echo "<br>";
echo "<b>{$mod_strings['LBL_PERFORM_TABLES']}</b>";
echo "<br>";
// create the SugarCRM database
if($setup_db_create_database) {
installLog("calling handleDbCreateDatabase()");
installerHook('pre_handleDbCreateDatabase');
handleDbCreateDatabase();
installerHook('post_handleDbCreateDatabase');
} else {
// ensure the charset and collation are utf8
installLog("calling handleDbCharsetCollation()");
installerHook('pre_handleDbCharsetCollation');
handleDbCharsetCollation();
installerHook('post_handleDbCharsetCollation');
}
//Suite rebuild exts
/*require_once('ModuleInstall/ModuleInstaller.php');
$ModuleInstaller = new ModuleInstaller();
$ModuleInstaller->silent=true;
$ModuleInstaller->rebuild_modules();
$ModuleInstaller->rebuild_languages( array ('en_us' => 'English (US)',));
$ModuleInstaller->rebuild_extensions();
$ModuleInstaller->rebuild_tabledictionary();*/
// create the SugarCRM database user
if($setup_db_create_sugarsales_user){
installerHook('pre_handleDbCreateSugarUser');
handleDbCreateSugarUser();
installerHook('post_handleDbCreateSugarUser');
}
foreach( $beanFiles as $bean => $file ){
require_once( $file );
}
echo "<br>";
// load up the config_override.php file.
// This is used to provide default user settings
if( is_file("config_override.php") ){
require_once("config_override.php");
}
$db = DBManagerFactory::getInstance();
$startTime = microtime(true);
$focus = 0;
$processed_tables = array(); // for keeping track of the tables we have worked on
$empty = '';
$new_tables = 1; // is there ever a scenario where we DON'T create the admin user?
$new_config = 1;
$new_report = 1;
// add non-module Beans to this array to keep the installer from erroring.
$nonStandardModules = array (
//'Tracker',
);
/**
* loop through all the Beans and create their tables
*/
installLog("looping through all the Beans and create their tables");
//start by clearing out the vardefs
VardefManager::clearVardef();
installerHook('pre_createAllModuleTables');
foreach( $beanFiles as $bean => $file ) {
$doNotInit = array('Scheduler', 'SchedulersJob', 'ProjectTask','jjwg_Maps','jjwg_Address_Cache','jjwg_Areas','jjwg_Markers');
if(in_array($bean, $doNotInit)) {
$focus = new $bean(false);
} else {
$focus = new $bean();
}
if ( $bean == 'Configurator' )
continue;
$table_name = $focus->table_name;
installLog("processing table ".$focus->table_name);
// check to see if we have already setup this table
if(!in_array($table_name, $processed_tables)) {
if(!file_exists("modules/".$focus->module_dir."/vardefs.php")){
continue;
}
if(!in_array($bean, $nonStandardModules)) {
require_once("modules/".$focus->module_dir."/vardefs.php"); // load up $dictionary
if($dictionary[$focus->object_name]['table'] == 'does_not_exist') {
continue; // support new vardef definitions
}
} else {
continue; //no further processing needed for ignored beans.
}
// table has not been setup...we will do it now and remember that
$processed_tables[] = $table_name;
$focus->db->database = $db->database; // set db connection so we do not need to reconnect
if($setup_db_drop_tables) {
drop_table_install($focus);
installLog("dropping table ".$focus->table_name);
}
if(create_table_if_not_exist($focus)) {
installLog("creating table ".$focus->table_name);
if( $bean == "User" ){
$new_tables = 1;
}
if($bean == "Administration")
$new_config = 1;
}
installLog("creating Relationship Meta for ".$focus->getObjectName());
installerHook('pre_createModuleTable', array('module' => $focus->getObjectName()));
SugarBean::createRelationshipMeta($focus->getObjectName(), $db, $table_name, $empty, $focus->module_dir);
installerHook('post_createModuleTable', array('module' => $focus->getObjectName()));
echo ".";
} // end if()
}
installerHook('post_createAllModuleTables');
echo "<br>";
//// END TABLE STUFF
///////////////////////////////////////////////////////////////////////////////
//// START RELATIONSHIP CREATION
ksort($rel_dictionary);
foreach( $rel_dictionary as $rel_name => $rel_data ){
$table = $rel_data['table'];
if( $setup_db_drop_tables ){
if( $db->tableExists($table) ){
$db->dropTableName($table);
}
}
if( !$db->tableExists($table) ){
$db->createTableParams($table, $rel_data['fields'], $rel_data['indices']);
}
SugarBean::createRelationshipMeta($rel_name,$db,$table,$rel_dictionary,'');
}
///////////////////////////////////////////////////////////////////////////////
//// START CREATE DEFAULTS
echo "<br>";
echo "<b>{$mod_strings['LBL_PERFORM_CREATE_DEFAULT']}</b><br>";
echo "<br>";
installLog("Begin creating Defaults");
installerHook('pre_createDefaultSettings');
if ($new_config) {
installLog("insert defaults into config table");
insert_default_settings();
}
installerHook('post_createDefaultSettings');
installerHook('pre_createUsers');
if ($new_tables) {
echo $line_entry_format.$mod_strings['LBL_PERFORM_DEFAULT_USERS'].$line_exit_format;
installLog($mod_strings['LBL_PERFORM_DEFAULT_USERS']);
create_default_users();
echo $mod_strings['LBL_PERFORM_DONE'];
} else {
echo $line_entry_format.$mod_strings['LBL_PERFORM_ADMIN_PASSWORD'].$line_exit_format;
installLog($mod_strings['LBL_PERFORM_ADMIN_PASSWORD']);
$db->setUserName($setup_db_sugarsales_user);
$db->setUserPassword($setup_db_sugarsales_password);
set_admin_password($setup_site_admin_password);
echo $mod_strings['LBL_PERFORM_DONE'];
}
installerHook('post_createUsers');
// default OOB schedulers
echo $line_entry_format.$mod_strings['LBL_PERFORM_DEFAULT_SCHEDULER'].$line_exit_format;
installLog($mod_strings['LBL_PERFORM_DEFAULT_SCHEDULER']);
$scheduler = new Scheduler();
installerHook('pre_createDefaultSchedulers');
$scheduler->rebuildDefaultSchedulers();
installerHook('post_createDefaultSchedulers');
echo $mod_strings['LBL_PERFORM_DONE'];
// Enable Sugar Feeds and add all feeds by default
installLog("Enable SugarFeeds");
enableSugarFeeds();
// Enable the InsideView connector and add all modules
//installLog("Enable InsideView Connector");
//enableInsideViewConnector();
// Install the logic hook for FTS
/*installLog("Creating FTS logic hook");
if (!function_exists('createFTSLogicHook')) {
function createFTSLogicHook($filePath = 'application/Ext/LogicHooks/logichooks.ext.php')
{
$customFileLoc = create_custom_directory($filePath);
$fp = sugar_fopen($customFileLoc, 'wb');
$contents = <<<CIA
<?php
if (!isset(\$hook_array) || !is_array(\$hook_array)) {
\$hook_array = array();
}
if (!isset(\$hook_array['after_save']) || !is_array(\$hook_array['after_save'])) {
\$hook_array['after_save'] = array();
}
\$hook_array['after_save'][] = array(1, 'fts', 'include/SugarSearchEngine/SugarSearchEngineQueueManager.php', 'SugarSearchEngineQueueManager', 'populateIndexQueue');
CIA;
fwrite($fp,$contents);
fclose($fp);
}
}
createFTSLogicHook();
// also write it to Extension directory so it won't be lost when rebuilding extensions
createFTSLogicHook('Extension/application/Ext/LogicHooks/SugarFTSHooks.php');*/
///////////////////////////////////////////////////////////////////////////
//// FINALIZE LANG PACK INSTALL
if(isset($_SESSION['INSTALLED_LANG_PACKS']) && is_array($_SESSION['INSTALLED_LANG_PACKS']) && !empty($_SESSION['INSTALLED_LANG_PACKS'])) {
updateUpgradeHistory();
}
///////////////////////////////////////////////////////////////////////////
//// HANDLE SUGAR VERSIONS
require_once('modules/Versions/InstallDefaultVersions.php');
require_once('modules/Connectors/InstallDefaultConnectors.php');
///////////////////////////////////////////////////////////////////////////////
//// INSTALL PASSWORD TEMPLATES
include('install/seed_data/Advanced_Password_SeedData.php');
///////////////////////////////////////////////////////////////////////////////
//// SETUP DONE
installLog("Installation has completed *********");
$memoryUsed = '';
if(function_exists('memory_get_usage')) {
$memoryUsed = $mod_strings['LBL_PERFORM_OUTRO_5'].memory_get_usage().$mod_strings['LBL_PERFORM_OUTRO_6'];
}
$errTcpip = '';
$fp = @fsockopen("www.suitecrm.com", 80, $errno, $errstr, 3);
if (!$fp) {
$errTcpip = "<p>{$mod_strings['ERR_PERFORM_NO_TCPIP']}</p>";
}
if ($fp && (!isset( $_SESSION['oc_install']) || $_SESSION['oc_install'] == false)) {
@fclose($fp);
if ( $next_step == 9999 )
$next_step = 8;
$fpResult =<<<FP
<form action="install.php" method="post" name="form" id="form">
<input type="hidden" name="current_step" value="{$next_step}">
<table cellspacing="0" cellpadding="0" border="0" class="stdTable">
<tr>
<td>
</td>
<td><input class="button" type="submit" name="goto" value="{$mod_strings['LBL_NEXT']}" id="button_next2"/></td>
</tr>
</table>
</form>
FP;
} else {
$fpResult =<<<FP
<table cellspacing="0" cellpadding="0" border="0" class="stdTable">
<tr>
<td> </td>
<td>
<form action="index.php" method="post" name="formFinish" id="formFinish">
<input type="hidden" name="default_user_name" value="admin" />
<input class="button" type="submit" name="next" value="{$mod_strings['LBL_PERFORM_FINISH']}" id="button_next2"/>
</form>
</td>
</tr>
</table>
FP;
}
if( isset($_SESSION['setup_site_sugarbeet_automatic_checks']) && $_SESSION['setup_site_sugarbeet_automatic_checks'] == true){
set_CheckUpdates_config_setting('automatic');
}else{
set_CheckUpdates_config_setting('manual');
}
if(!empty($_SESSION['setup_system_name'])){
$admin=new Administration();
$admin->saveSetting('system','name',$_SESSION['setup_system_name']);
}
// Bug 28601 - Set the default list of tabs to show
$enabled_tabs = array();
$enabled_tabs[] = 'Home';
$enabled_tabs[] = 'Accounts';
$enabled_tabs[] = 'Contacts';
$enabled_tabs[] = 'Opportunities';
$enabled_tabs[] = 'Leads';
$enabled_tabs[] = 'AOS_Quotes';
$enabled_tabs[] = 'Calendar';
$enabled_tabs[] = 'Documents';
$enabled_tabs[] = 'Emails';
$enabled_tabs[] = 'Campaigns';
$enabled_tabs[] = 'Calls';
$enabled_tabs[] = 'Meetings';
$enabled_tabs[] = 'Tasks';
$enabled_tabs[] = 'Notes';
$enabled_tabs[] = 'AOS_Invoices';
$enabled_tabs[] = 'AOS_Contracts';
$enabled_tabs[] = 'Cases';
$enabled_tabs[] = 'Prospects';
$enabled_tabs[] = 'ProspectLists';
$enabled_tabs[] = 'Projects';
$enabled_tabs[] = 'FP_events';
$enabled_tabs[] = 'FP_Event_Locations';
$enabled_tabs[] = 'AOS_Products';
$enabled_tabs[] = 'AOS_Product_Categories';
$enabled_tabs[] = 'AOS_PDF_Templates';
$enabled_tabs[] = 'jjwg_Maps';
$enabled_tabs[] = 'jjwg_Markers';
$enabled_tabs[] = 'jjwg_Areas';
$enabled_tabs[] = 'jjwg_Address_Cache';
$enabled_tabs[] = 'AOR_Reports';
$enabled_tabs[] = 'AOW_WorkFlow';
installerHook('pre_setSystemTabs');
require_once('modules/MySettings/TabController.php');
$tabs = new TabController();
$tabs->set_system_tabs($enabled_tabs);
installerHook('post_setSystemTabs');
include_once('install/suite_install/suite_install.php');
post_install_modules();
//Call rebuildSprites
if(function_exists('imagecreatetruecolor'))
{
require_once('modules/UpgradeWizard/uw_utils.php');
rebuildSprites(true);
}
///////////////////////////////////////////////////////////////////////////////
//// START DEMO DATA
// populating the db with seed data
installLog("populating the db with seed data");
if( $_SESSION['demoData'] != 'no' ){
installerHook('pre_installDemoData');
set_time_limit( 301 );
echo "<br>";
echo "<b>{$mod_strings['LBL_PERFORM_DEMO_DATA']}</b>";
echo "<br><br>";
print( $render_table_close );
print( $render_table_open );
global $current_user;
$current_user = new User();
$current_user->retrieve(1);
include("install/populateSeedData.php");
installerHook('post_installDemoData');
}
$endTime = microtime(true);
$deltaTime = $endTime - $startTime;
if( count( $bottle ) > 0 ){
foreach( $bottle as $bottle_message ){
$bottleMsg .= "{$bottle_message}\n";
}
} else {
$bottleMsg = $mod_strings['LBL_PERFORM_SUCCESS'];
}
installerHook('post_installModules');
$out =<<<EOQ
<br><p><b>{$mod_strings['LBL_PERFORM_OUTRO_1']} {$setup_sugar_version} {$mod_strings['LBL_PERFORM_OUTRO_2']}</b></p>
{$mod_strings['LBL_PERFORM_OUTRO_3']} {$deltaTime} {$mod_strings['LBL_PERFORM_OUTRO_4']}<br />
{$memoryUsed}
{$errTcpip}
</td>
</tr>
<tr>
<td align="right" colspan="2">
<hr>
<table cellspacing="0" cellpadding="0" border="0" class="stdTable">
<tr>
<td>
{$fpResult}
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<!--
<bottle>{$bottleMsg}</bottle>
-->
EOQ;
echo $out;
?>