From eb4312db9ba4bb272a9c55feb4205197fd4d0466 Mon Sep 17 00:00:00 2001
From: Clemente Raposo
';
+ $msg .= 'Although the minimum PHP version required is ';
+ $msg .= constant('SUITECRM_PHP_MIN_VERSION') . ', ';
+ $msg .= 'is not recommended due to the large number of fixed bugs, including security fixes, ';
+ $msg .= 'released in the more modern versions.
';
+ $msg .= 'You are using PHP version ' . constant('PHP_VERSION') . ', which is EOL: http://php.net/eol.php.
';
+
+ return [
+ 'success' => false,
+ 'messages' => [$msg]
+ ];
+
+ }
+
+ $session_id = session_id();
+ if (empty($session_id)) {
+ @session_start();
+ }
+
+ $GLOBALS['installing'] = true;
+ define('SUGARCRM_IS_INSTALLING', $GLOBALS['installing']);
+ $GLOBALS['sql_queries'] = 0;
+
+
+ require_once('include/SugarLogger/LoggerManager.php');
+ require_once('sugar_version.php');
+ require_once('suitecrm_version.php');
+ require_once('install/install_utils.php');
+ require_once('install/install_defaults.php');
+ require_once('include/TimeDate.php');
+ require_once('include/Localization/Localization.php');
+ require_once('include/SugarTheme/SugarTheme.php');
+ require_once('include/utils/LogicHook.php');
+ require_once('data/SugarBean.php');
+ require_once('include/entryPoint.php');
+ require_once('jssource/minify.php'); // Do we need?
+ require_once('config.php');
+
+
+ if (!empty($sugar_config['installer_locked'])) {
+ return [
+ 'success' => false,
+ 'messages' => ['Installer has been disabled'],
+ ];
+ }
+
+ //check to see if the script files need to be rebuilt, add needed variables to request array
+ $_REQUEST['root_directory'] = getcwd();
+ $_REQUEST['js_rebuild_concat'] = 'rebuild';
+
+ //Set whether the install is silent or not
+ $silentInstall = true;
+
+
+ $timedate = TimeDate::getInstance();
+ // cn: set php.ini settings at entry points
+ setPhpIniSettings();
+
+ $locale = new Localization();
+
+ $GLOBALS['log'] = LoggerManager::getLogger();
+
+ $setup_sugar_version = $suitecrm_version;
+
+ $install_script = true;
+
+ ///////////////////////////////////////////////////////////////////////////////
+ //// INSTALL RESOURCE SETUP
+ $css = 'install/install.css';
+ $icon = 'include/images/sugar_icon.ico';
+ $sugar_md = 'include/images/sugar_md_open.png';
+ $loginImage = 'include/images/suitecrm_login.png';
+ $common = 'install/installCommon.js';
+ [$supportedLanguages, $default_lang, $current_language, $mod_strings, $app_list_strings] = $this->loadInstallLaguages($supportedLanguages ?? []);
+
+ //get the url for the helper link
+ global $help_url;
+ $help_url = get_help_button_url();
+
+
+ foreach ($installer_defaults ?? [] as $key => $val) {
+ if (!isset($_SESSION[$key])) {
+ $_SESSION[$key] = $val;
+ }
+ }
+
+ // always perform
+ clean_special_arguments();
+
+ //define web root, which will be used as default for site_url
+ if ($_SERVER['SERVER_PORT'] == '80') {
+ $web_root = $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
+ } else {
+ $web_root = $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['PHP_SELF'];
+ }
+ $web_root = str_replace("/install.php", "", $web_root);
+ $web_root = "http://$web_root";
+
+ if (empty($sugar_config['cache_dir']) && !empty($_SESSION['cache_dir'])) {
+ $sugar_config['cache_dir'] = $_SESSION['cache_dir'];
+ }
+
+ // set the form's php var to the loaded config's var else default to sane settings
+ if (!isset($_SESSION['setup_site_url']) || empty($_SESSION['setup_site_url'])) {
+ if (isset($sugar_config['site_url']) && !empty($sugar_config['site_url'])) {
+ $_SESSION['setup_site_url'] = $sugar_config['site_url'];
+ } else {
+ $_SESSION['setup_site_url'] = $web_root;
+ }
+ }
+
+ if (!isset($_SESSION['setup_system_name']) || empty($_SESSION['setup_system_name'])) {
+ $_SESSION['setup_system_name'] = 'SugarCRM';
+ }
+ if (!isset($_SESSION['setup_site_session_path']) || empty($_SESSION['setup_site_session_path'])) {
+ $_SESSION['setup_site_session_path'] = (isset($sugar_config['session_dir'])) ? $sugar_config['session_dir'] : '';
+ }
+ if (!isset($_SESSION['setup_site_log_dir']) || empty($_SESSION['setup_site_log_dir'])) {
+ $_SESSION['setup_site_log_dir'] = (isset($sugar_config['log_dir'])) ? $sugar_config['log_dir'] : '.';
+ }
+ if (!isset($_SESSION['setup_site_guid']) || empty($_SESSION['setup_site_guid'])) {
+ $_SESSION['setup_site_guid'] = (isset($sugar_config['unique_key'])) ? $sugar_config['unique_key'] : '';
+ }
+ if (!isset($_SESSION['cache_dir']) || empty($_SESSION['cache_dir'])) {
+ $_SESSION['cache_dir'] = isset($sugar_config['cache_dir']) ? $sugar_config['cache_dir'] : 'cache/';
+ }
+
+ // Add check here to see if a silent install config file exists; if so then launch silent installer
+
+
+ pullSilentInstallVarsIntoSession();
+
+ $validation_errors = array();
+
+ $the_file = 'SilentInstall';
+
+ $si_errors = false;
+
+ /*
+ * Make sure we are using the correct unique_key. The logic
+ * to save a custom unique_key happens lower in the process.
+ * However because of the initial FTS check we are already
+ * relying on this value which will not get reinitialized
+ * when we actual need it during index creation because
+ * SilentInstaller runs in one single process.
+ */
+ if (!empty($_SESSION['setup_site_specify_guid']) && !empty($_SESSION['setup_site_guid'])) {
+ $sugar_config['unique_key'] = $_SESSION['setup_site_guid'];
+ } else {
+ $sugar_config['unique_key'] = md5(create_guid());
+ }
+
+ $validation_errors = validate_dbConfig();
+ if ((is_countable($validation_errors) ? count($validation_errors) : 0) > 0) {
+ $the_file = 'dbConfig_a.php';
+ $si_errors = true;
+ }
+ $validation_errors = validate_siteConfig('a');
+ if ((is_countable($validation_errors) ? count($validation_errors) : 0) > 0) {
+ $the_file = 'siteConfig_a.php';
+ $si_errors = true;
+ }
+ $validation_errors = validate_siteConfig('b');
+ if ((is_countable($validation_errors) ? count($validation_errors) : 0) > 0) {
+ $the_file = 'siteConfig_b.php';
+ $si_errors = true;
+ }
+
+ if ($si_errors) {
+ return [
+ 'success' => false,
+ 'messages' => $validation_errors ?? [],
+ ];
+ }
+
+ //since this is a SilentInstall we still need to make sure that
+ //the appropriate files are writable
+ // config.php
+ $result = make_writable('./config.php');
+
+ if (!$result) {
+ return [
+ 'success' => false,
+ 'messages' => ['Not able to write to /public/legacy/config.php'],
+ ];
+ }
+
+ // custom dir
+ make_writable('./custom');
+
+
+ // modules dir
+ recursive_make_writable('./modules');
+
+ // cache dir
+ create_writable_dir(sugar_cached('custom_fields'));
+ create_writable_dir(sugar_cached('dyn_lay'));
+ create_writable_dir(sugar_cached('images'));
+ create_writable_dir(sugar_cached('modules'));
+ create_writable_dir(sugar_cached('layout'));
+ create_writable_dir(sugar_cached('pdf'));
+ create_writable_dir(sugar_cached('upload/import'));
+ create_writable_dir(sugar_cached('xml'));
+ create_writable_dir(sugar_cached('include/javascript'));
+ recursive_make_writable(sugar_cached('modules'));
+
+ // public dir
+ recursive_make_writable('./public');
+
+ installerHook('pre_installFileRequire', ['the_file' => 'install/perform_setup.php']);
+ $performSetupResult = [];
+ try {
+ $this->performSetup();
+ } catch (Exception $e) {
+ return [
+ 'success' => false,
+ 'messages' => [$e->getMessage()],
+ 'debug' => $this->getDebug()
+ ];
+ }
+ installerHook('post_installFileRequire', ['the_file' => 'install/perform_setup.php']);
+
+ if (isset($performSetupResult['success']) && $performSetupResult['success'] === false) {
+ return $performSetupResult;
+ }
+
+ return [
+ 'success' => true,
+ 'messages' => []
+ ];
+ }
+
+ protected function performSetup()
+ {
+
+ global $mod_strings;
+ global $install_script;
+
+ $this->installStatus($mod_strings['LBL_START'], null, true, '');
+
+ // 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) {
+ return [
+ 'success' => false,
+ 'messages' => ['Install error: Unable to process script directly. ']
+ ];
+ }
+
+ 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');
+
+ global $trackerManager;
+
+ $trackerManager = TrackerManager::getInstance();
+ $trackerManager->pause();
+
+ global $cache_dir;
+ global $dictionary;
+ global $line_entry_format;
+ global $line_exit_format;
+ global $rel_dictionary;
+ global $render_table_close;
+ global $render_table_open;
+ global $setup_db_admin_password;
+ global $setup_db_admin_user_name;
+ global $setup_db_create_database;
+ global $setup_db_create_sugarsales_user;
+ global $setup_db_database_name;
+ global $setup_db_drop_tables;
+ global $setup_db_host_instance;
+ global $setup_db_port_num;
+ global $setup_db_host_name;
+ global $demoData;
+ global $setup_db_sugarsales_password;
+ global $setup_db_sugarsales_user;
+ global $setup_site_admin_user_name;
+ global $setup_site_admin_password;
+ global $setup_site_guid;
+ global $setup_site_url;
+ global $parsed_url;
+ global $setup_site_host_name;
+ global $setup_site_log_dir;
+ global $setup_site_log_file;
+ global $setup_site_session_path;
+ global $setup_site_log_level;
+ global $beanFiles;
+
+
+ $cache_dir = sugar_cached("");
+ $line_entry_format = "     ";
+ $line_exit_format = "...   ";
+ $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((string)$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';
+
+ $langHeader = get_language_header();
+
+ $this->installStatus($mod_strings['STAT_CONFIGURATION'], null, false, '');
+ $this->addDebug("calling handleSugarConfig()");
+ $bottle = handleSugarConfig();
+
+ $server_software = $_SERVER["SERVER_SOFTWARE"];
+ if (str_contains((string)$server_software, 'Microsoft-IIS')) {
+ $this->addDebug("calling handleWebConfig()");
+ handleWebConfig();
+ } else {
+ $this->addDebug("calling handleHtaccess()");
+ handleHtaccess();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////
+ //// START TABLE STUFF
+
+ $this->addDebug($mod_strings['LBL_PERFORM_TABLES']);
+
+ // create the SugarCRM database
+ if ($setup_db_create_database) {
+ $this->addDebug("calling handleDbCreateDatabase()");
+ installerHook('pre_handleDbCreateDatabase');
+ handleDbCreateDatabase();
+ installerHook('post_handleDbCreateDatabase');
+ } else {
+
+ // ensure the charset and collation are utf8
+ $this->addDebug("calling handleDbCharsetCollation()");
+ installerHook('pre_handleDbCharsetCollation');
+ handleDbCharsetCollation();
+ installerHook('post_handleDbCharsetCollation');
+ }
+
+ // 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);
+ }
+
+ // 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");
+ }
+
+ global $startTime;
+ global $focus;
+ global $processed_tables;
+ global $db;
+ global $empty;
+ global $new_tables;
+ global $new_config;
+ global $new_report;
+ global $nonStandardModules;
+
+
+ $db = DBManagerFactory::getInstance();
+ $startTime = microtime(true);
+ $focus = 0;
+ $processed_tables = []; // 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 = [//'Tracker',
+ ];
+
+
+ /**
+ * loop through all the Beans and create their tables
+ */
+ $this->installStatus($mod_strings['STAT_CREATE_DB']);
+ $this->addDebug("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 = ['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;
+ $this->addDebug("processing table " . $focus->table_name);
+ // check to see if we have already setup this table
+ if (!in_array($table_name, $processed_tables, true)) {
+ 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 (isset($dictionary[$focus->object_name]['table']) && $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);
+ $this->addDebug("dropping table " . $focus->table_name);
+ }
+
+ if (create_table_if_not_exist($focus)) {
+ $this->addDebug("creating table " . $focus->table_name);
+ if ($bean == "User") {
+ $new_tables = 1;
+ }
+ if ($bean == "Administration") {
+ $new_config = 1;
+ }
+ }
+
+ $this->addDebug("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()));
+ } // end if()
+ }
+
+
+ installerHook('post_createAllModuleTables');
+
+ //// 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
+ $this->addDebug($mod_strings['LBL_PERFORM_CREATE_DEFAULT']);
+
+ $this->installStatus($mod_strings['STAT_CREATE_DEFAULT_SETTINGS']);
+ $this->addDebug("Begin creating Defaults");
+ installerHook('pre_createDefaultSettings');
+ if ($new_config) {
+ $this->addDebug("insert defaults into config table");
+ insert_default_settings();
+ }
+ installerHook('post_createDefaultSettings');
+
+
+ installerHook('pre_createUsers');
+ if ($new_tables) {
+ $this->addDebug($mod_strings['LBL_PERFORM_DEFAULT_USERS']);
+ create_default_users();
+ $this->addDebug($mod_strings['LBL_PERFORM_DEFAULT_DONE']);
+ } else {
+ $this->addDebug($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);
+ $this->addDebug($mod_strings['LBL_PERFORM_DONE']);
+ }
+ installerHook('post_createUsers');
+
+
+ // default OOB schedulers
+
+ $this->addDebug($mod_strings['LBL_PERFORM_DEFAULT_SCHEDULER']);
+ $scheduler = BeanFactory::newBean('Schedulers');
+ installerHook('pre_createDefaultSchedulers');
+ $scheduler->rebuildDefaultSchedulers();
+ installerHook('post_createDefaultSchedulers');
+ $this->addDebug($mod_strings['LBL_PERFORM_DONE']);
+
+
+ // Enable Sugar Feeds and add all feeds by default
+ $this->addDebug("Enable SugarFeeds");
+ enableSugarFeeds();
+
+ // Install the logic hook for WorkFLow
+ $this->addDebug("Creating WorkFlow logic hook");
+ if (!function_exists('createWorkFlowLogicHook')) {
+ function createWorkFlowLogicHook($filePath = 'Extension/application/Ext/LogicHooks/AOW_WorkFlow_Hook.php')
+ {
+ $customFileLoc = create_custom_directory($filePath);
+ $templateLogicHookFileContents = file_get_contents('include/portability/Install/templates/workflow_logic_hook.php');
+ $fp = sugar_fopen($customFileLoc, 'wb');
+ fwrite($fp, $templateLogicHookFileContents);
+ fclose($fp);
+
+ }
+ }
+ createWorkFlowLogicHook();
+
+ ///////////////////////////////////////////////////////////////////////////
+ //// FINALIZE LANG PACK INSTALL
+ if (isset($_SESSION['INSTALLED_LANG_PACKS']) && is_array($_SESSION['INSTALLED_LANG_PACKS']) && !empty($_SESSION['INSTALLED_LANG_PACKS'])) {
+ updateUpgradeHistory();
+ }
+
+
+ //require_once('modules/Connectors/InstallDefaultConnectors.php');
+
+ ///////////////////////////////////////////////////////////////////////////////
+ //// INSTALL PASSWORD TEMPLATES
+ include('install/seed_data/Advanced_Password_SeedData.php');
+
+ ///////////////////////////////////////////////////////////////////////////////
+ //// SETUP DONE
+ $this->addDebug("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'];
+ $this->addDebug('Memory used: ' . $memoryUsed);
+ }
+
+
+ $errTcpip = '';
+ $fp = @fsockopen("www.suitecrm.com", 80, $errno, $errstr, 3);
+ if (!$fp) {
+ $this->addDebug($mod_strings['ERR_PERFORM_NO_TCPIP_SIMPLE']);
+ }
+
+ 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 = BeanFactory::newBean('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[] = 'Project';
+ $enabled_tabs[] = 'AM_ProjectTemplates';
+ $enabled_tabs[] = 'AM_TaskTemplates';
+ $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[] = 'AOR_Reports';
+ $enabled_tabs[] = 'AOK_KnowledgeBase';
+ $enabled_tabs[] = 'AOK_Knowledge_Base_Categories';
+ $enabled_tabs[] = 'EmailTemplates';
+ $enabled_tabs[] = 'Surveys';
+
+ //Beginning of the scenario implementations
+ //We need to load the tabs so that we can remove those which are scenario based and un-selected
+ //Remove the custom tabConfig as this overwrites the complete list containined in the include/tabConfig.php
+ if (file_exists('custom/include/tabConfig.php')) {
+ unlink('custom/include/tabConfig.php');
+ }
+ require_once('include/tabConfig.php');
+
+ //Remove the custom dashlet so that we can use the complete list of defaults to filter by category
+ if (file_exists('custom/modules/Home/dashlets.php')) {
+ unlink('custom/modules/Home/dashlets.php');
+ }
+
+ //Check if the folder is in place
+ if (!file_exists('custom/modules/Home')) {
+ sugar_mkdir('custom/modules/Home', 0775);
+ }
+
+ //Check if the folder is in place
+ if (!file_exists('custom/include')) {
+ sugar_mkdir('custom/include', 0775);
+ }
+
+
+ require_once('modules/Home/dashlets.php');
+
+ if (isset($_SESSION['installation_scenarios'])) {
+ foreach ($_SESSION['installation_scenarios'] as $scenario) {
+ //If the item is not in $_SESSION['scenarios'], then unset them as they are not required
+ if (!in_array($scenario['key'], $_SESSION['scenarios'])) {
+ foreach ($scenario['modules'] as $module) {
+ if (($removeKey = array_search($module, $enabled_tabs, true)) !== false) {
+ unset($enabled_tabs[$removeKey]);
+ }
+ }
+
+ //Loop through the dashlets to remove from the default home page based on this scenario
+ foreach ($scenario['dashlets'] as $dashlet) {
+ if (isset($defaultDashlets[$dashlet])) {
+ unset($defaultDashlets[$dashlet]);
+ }
+ }
+
+ //If the scenario has an associated group tab, remove accordingly (by not adding to the custom tabconfig.php
+ if (isset($scenario['groupedTabs'])) {
+ unset($GLOBALS['tabStructure'][$scenario['groupedTabs']]);
+ }
+ }
+ }
+ }
+
+ //Have a 'core' options, with accounts / contacts if no other scenario is selected
+ if (!is_null($_SESSION['scenarios'])) {
+ unset($GLOBALS['tabStructure']['LBL_TABGROUP_DEFAULT']);
+ }
+
+
+ //Write the tabstructure to custom so that the grouping are not shown for the un-selected scenarios
+ $fileContents = "set_system_tabs($enabled_tabs);
+ installerHook('post_setSystemTabs');
+ include_once('install/suite_install/suite_install.php');
+
+ post_install_modules();
+
+ ///////////////////////////////////////////////////////////////////////////////
+ //// START DEMO DATA
+
+ // populating the db with seed data
+ if ($_SESSION['demoData'] !== 'no') {
+ $this->addDebug("Populating the db with seed data");
+ installerHook('pre_installDemoData');
+ set_time_limit(301);
+
+ global $current_user;
+ $current_user = BeanFactory::newBean('Users');
+ $current_user->retrieve(1);
+ include("install/populateSeedData.php");
+ installerHook('post_installDemoData');
+ }
+
+ /////////////////////////////////////////////////////////////
+ //// Store information by installConfig.php form
+
+ // save current superglobals and vars
+ $varStack['GLOBALS'] = $GLOBALS;
+ $varStack['defined_vars'] = get_defined_vars();
+
+ // restore previously posted form
+ $_REQUEST = array_merge($_REQUEST, $_SESSION);
+ $_POST = array_merge($_POST, $_SESSION);
+
+
+ $this->installStatus($mod_strings['STAT_INSTALL_FINISH']);
+ $this->addDebug('Save configuration settings..');
+
+ // <--------------------------------------------------------
+ // from ConfigurationConroller->action_saveadminwizard()
+ // ---------------------------------------------------------->
+
+ $this->addDebug('save locale');
+
+
+ //global $current_user;
+ $this->addDebug('new Administration');
+ $focus = BeanFactory::newBean('Administration');
+ $this->addDebug('retrieveSettings');
+ //$focus->retrieveSettings();
+ // switch off the adminwizard (mark that we have got past this point)
+ $this->addDebug('AdminWizard OFF');
+ $focus->saveSetting('system', 'adminwizard', 1);
+
+ $this->addDebug('saveConfig');
+ $focus->saveConfig();
+
+ $this->addDebug('new Configurator');
+ global $configurator;
+ $configurator = new Configurator();
+ $this->addDebug('populateFromPost');
+ $configurator->populateFromPost();
+
+
+ $this->addDebug('handleOverride');
+ // add local settings to config overrides
+ if (!empty($_SESSION['default_date_format'])) {
+ $sugar_config['default_date_format'] = $_SESSION['default_date_format'];
+ }
+ if (!empty($_SESSION['default_time_format'])) {
+ $sugar_config['default_time_format'] = $_SESSION['default_time_format'];
+ }
+ if (!empty($_SESSION['default_language'])) {
+ $sugar_config['default_language'] = $_SESSION['default_language'];
+ }
+ if (!empty($_SESSION['default_locale_name_format'])) {
+ $sugar_config['default_locale_name_format'] = $_SESSION['default_locale_name_format'];
+ }
+ //$configurator->handleOverride();
+
+
+ // save current web-server user for the cron user check mechanism:
+ $this->addDebug('addCronAllowedUser');
+ addCronAllowedUser(getRunningUser());
+
+
+ $this->addDebug('saveConfig');
+ $configurator->saveConfig();
+
+
+ // Bug 37310 - Delete any existing currency that matches the one we've just set the default to during the admin wizard
+ $this->addDebug('new Currency');
+ $currency = new Currency();
+ $this->addDebug('retrieve');
+ $currency->retrieve($currency->retrieve_id_by_name($_REQUEST['default_currency_name']));
+ if (!empty($currency->id)
+ && $currency->symbol == $_REQUEST['default_currency_symbol']
+ && $currency->iso4217 == $_REQUEST['default_currency_iso4217']) {
+ $currency->deleted = 1;
+ $this->addDebug('Save currency');
+ $currency->save();
+ }
+
+
+ $this->addDebug('Save user settings..');
+
+ // <------------------------------------------------
+ // from UsersController->action_saveuserwizard()
+ // ---------------------------------------------------------->
+
+
+ // set all of these default parameters since the Users save action will undo the defaults otherwise
+
+ // load admin
+ if (empty($current_user) || empty($current_user->id)) {
+ $current_user = BeanFactory::newBean('Users');
+ $current_user->retrieve(1);
+ $current_user->is_admin = '1';
+ }
+
+ if (empty($sugar_config)) {
+ $sugar_config = get_sugar_config_defaults();
+ }
+
+ // set local settings - if neccessary you can set here more fields as named in User module / EditView form...
+ if (isset($_REQUEST['timezone']) && $_REQUEST['timezone']) {
+ $current_user->setPreference('timezone', $_REQUEST['timezone']);
+ }
+
+ if (file_exists(__DIR__ . '/../modules/ACL/install_actions.php')) {
+ require_once(__DIR__ . '/../modules/ACL/install_actions.php');
+ }
+
+ $_POST['dateformat'] = $_REQUEST['default_date_format'];
+ $_POST['record'] = $current_user->id;
+ $_POST['is_admin'] = ($current_user->is_admin ? 'on' : '');
+ $_POST['use_real_names'] = true;
+ $_POST['reminder_checked'] = '1';
+ $_POST['reminder_time'] = 1800;
+ $_POST['email_reminder_time'] = 3600;
+ $_POST['mailmerge_on'] = 'on';
+ $_POST['receive_notifications'] = $current_user->receive_notifications;
+ $this->addDebug('DBG: SugarThemeRegistry::getDefault');
+ $_POST['user_theme'] = (string)SugarThemeRegistry::getDefault();
+
+ // save and redirect to new view
+ $_REQUEST['do_not_redirect'] = true;
+
+ // restore superglobals and vars
+ foreach ($varStack['GLOBALS'] ?? [] as $index => $item) {
+ $GLOBALS[$index] = $item;
+ }
+ foreach ($varStack['defined_vars'] as $__key => $__value) {
+ $$__key = $__value;
+ }
+
+
+ $endTime = microtime(true);
+ $deltaTime = $endTime - $startTime;
+
+ if (!is_array($bottle) || !is_object($bottle)) {
+ $bottle = $bottle;
+ LoggerManager::getLogger()->warn('Bottle needs to be an array to perform setup');
+ }
+
+
+ if (is_countable($bottle) && count($bottle) > 0) {
+ foreach ($bottle as $bottle_message) {
+ $this->addDebug($bottle_message);
+ }
+ } else {
+ $bottleMsg = $mod_strings['LBL_PERFORM_SUCCESS'];
+ }
+
+ installerHook('post_installModules');
+
+ $this->installStatus('Installation process finished');
+
+ }
+
+ protected function getSupportedInstallLanguages(): array
+ {
+ $supportedLanguages = [
+ 'en_us' => 'English (US)',
+ ];
+
+ if (file_exists('install/lang.config.php')) {
+ $config = [];
+ include('install/lang.config.php');
+ if (!empty($config['languages'])) {
+ foreach ($config['languages'] as $k => $v) {
+ if (file_exists('install/language/' . $k . '.lang.php')) {
+ $supportedLanguages[$k] = $v;
+ }
+ }
+ }
+ }
+ return $supportedLanguages;
+ }
+
+ /**
+ * @param array $supportedLanguages
+ * @return array
+ */
+ protected function loadInstallLaguages(array $supportedLanguages): array
+ {
+///////////////////////////////////////////////////////////////////////////////
+ //// INSTALLER LANGUAGE
+
+ $supportedLanguages = $this->getSupportedInstallLanguages();
+
+ // after install language is selected, use that pack
+ global $default_lang;
+ $default_lang = 'en_us';
+ if (!isset($_POST['language']) && (!isset($_SESSION['language']) && empty($_SESSION['language']))) {
+ if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
+ $lang = parseAcceptLanguage();
+ if (isset($supportedLanguages[$lang])) {
+ $_POST['language'] = $lang;
+ } else {
+ $_POST['language'] = $default_lang;
+ }
+ }
+ }
+
+ if (isset($_POST['language'])) {
+ $_SESSION['language'] = str_replace('-', '_', (string)$_POST['language']);
+ }
+
+ global $current_language;
+ $current_language = isset($_SESSION['language']) ? $_SESSION['language'] : $default_lang;
+
+ if (file_exists("install/language/{$current_language}.lang.php")) {
+ require_once("install/language/{$current_language}.lang.php");
+ } else {
+ require_once("install/language/{$default_lang}.lang.php");
+ }
+
+ global $mod_strings;
+
+ if ($current_language != 'en_us') {
+ $my_mod_strings = $mod_strings;
+ include('install/language/en_us.lang.php');
+ $mod_strings = sugarLangArrayMerge($mod_strings, $my_mod_strings);
+ }
+
+ global $app_list_strings;
+ $app_list_strings = return_app_list_strings_language($current_language);
+ return array($supportedLanguages, $default_lang, $current_language, $mod_strings, $app_list_strings);
+ //// END INSTALLER LANGUAGE
+ ///////////////////////////////////////////////////////////////////////////////
+ }
+
+ protected function installStatus($msg, $cmd = null, $overwrite = false, $before = '[ok]
')
+ {
+ $fname = 'install/status.json';
+ if (!$overwrite && file_exists($fname)) {
+ $stat = json_decode(file_get_contents($fname), null, 512, JSON_THROW_ON_ERROR);
+ $msg = $stat->message . $before . $msg;
+ }
+
+ $json = json_encode(
+ array(
+ 'message' => $msg,
+ 'command' => $cmd,
+ ), JSON_THROW_ON_ERROR
+ );
+
+ $this->addDebug($json);
+
+ file_put_contents($fname, $json);
+ }
+
+ public function getDebug(): array
+ {
+ return $this->debug;
+ }
+
+ protected function resetDebug(): array
+ {
+ return $this->debug = [];
+ }
+
+ protected function addDebug(string $message): void
+ {
+ $this->debug[] = $message;
+ }
+
+ public function getMessages(): array
+ {
+ return $this->messages;
+ }
+
+ protected function resetMessages(): array
+ {
+ return $this->messages = [];
+ }
+
+
+ protected function addMessage(array $message): void
+ {
+ $this->messages[] = $message;
+ }
+
+}
diff --git a/public/legacy/include/portability/Install/templates/workflow_logic_hook.php b/public/legacy/include/portability/Install/templates/workflow_logic_hook.php
new file mode 100644
index 000000000..21a46d3c2
--- /dev/null
+++ b/public/legacy/include/portability/Install/templates/workflow_logic_hook.php
@@ -0,0 +1,11 @@
+ ' file.',
'ERR_PERFORM_HTACCESS_3' => 'If you want to secure your log file from being accessible via browser, create an .htaccess file in your log directory with the line:',
'ERR_PERFORM_NO_TCPIP' => 'We could not detect an Internet connection. When you do have a connection, please visit https://www.suitecrm.com/ to register with SuiteCRM. By letting us know a little bit about how your company plans to use SuiteCRM, we can ensure we are always delivering the right application for your business needs.',
+ 'ERR_PERFORM_NO_TCPIP_SIMPLE' => 'We could not detect an Internet connection.',
'ERR_SESSION_DIRECTORY_NOT_EXISTS' => 'Session directory provided is not a valid directory.',
'ERR_SESSION_DIRECTORY' => 'Session directory provided is not a writable directory.',
'ERR_SESSION_PATH' => 'Session path is required if you wish to specify your own.',
diff --git a/public/legacy/install/perform_setup_service.php b/public/legacy/install/perform_setup_service.php
deleted file mode 100644
index 05d2ead96..000000000
--- a/public/legacy/install/perform_setup_service.php
+++ /dev/null
@@ -1,743 +0,0 @@
-')
-{
- $fname = 'install/status.json';
- if (!$overwrite && file_exists($fname)) {
- $stat = json_decode(file_get_contents($fname), null, 512, JSON_THROW_ON_ERROR);
- //$msg = json_encode($stat);
- $msg = $stat->message . $before . $msg;
- }
- file_put_contents(
- $fname, json_encode(
- array(
- 'message' => $msg,
- 'command' => $cmd,
- ), JSON_THROW_ON_ERROR
- )
- );
-}
-
-installStatus($mod_strings['LBL_START'], null, true, '');
-
-// 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) {
- $performSetupResult = [
- 'success' => false,
- 'messages' => ['Install error: Unable to process script directly. ']
- ];
- return;
-}
-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');
-
-global $trackerManager;
-
-$trackerManager = TrackerManager::getInstance();
-$trackerManager->pause();
-
-global $cache_dir;
-global $line_entry_format;
-global $line_exit_format;
-global $rel_dictionary;
-global $render_table_close;
-global $render_table_open;
-global $setup_db_admin_password;
-global $setup_db_admin_user_name;
-global $setup_db_create_database;
-global $setup_db_create_sugarsales_user;
-global $setup_db_database_name;
-global $setup_db_drop_tables;
-global $setup_db_host_instance;
-global $setup_db_port_num;
-global $setup_db_host_name;
-global $demoData;
-global $setup_db_sugarsales_password;
-global $setup_db_sugarsales_user;
-global $setup_site_admin_user_name;
-global $setup_site_admin_password;
-global $setup_site_guid;
-global $setup_site_url;
-global $parsed_url;
-global $setup_site_host_name;
-global $setup_site_log_dir;
-global $setup_site_log_file;
-global $setup_site_session_path;
-global $setup_site_log_level;
-
-
-$cache_dir = sugar_cached("");
-$line_entry_format = "     ";
-$line_exit_format = "...   ";
-$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((string)$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';
-
-$langHeader = get_language_header();
-
-$install_db_setup_messages = [];
-
-installStatus($mod_strings['STAT_CONFIGURATION'], null, false, '');
-installLog("calling handleSugarConfig()");
-$bottle = handleSugarConfig();
-//installLog("calling handleLog4Php()");
-//handleLog4Php();
-
-$server_software = $_SERVER["SERVER_SOFTWARE"];
-if (strpos((string)$server_software, 'Microsoft-IIS') !== false) {
- installLog("calling handleWebConfig()");
- handleWebConfig();
-} else {
- installLog("calling handleHtaccess()");
- handleHtaccess();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//// START TABLE STUFF
-
-$install_db_setup_messages[] = $mod_strings['LBL_PERFORM_TABLES'];
-
-// 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');
-}
-
-// 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);
-}
-// 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");
-}
-
-global $db;
-global $startTime;
-global $focus;
-global $processed_tables;
-global $db;
-global $empty;
-global $new_tables;
-global $new_config;
-global $new_report;
-global $nonStandardModules;
-
-
-$db = DBManagerFactory::getInstance();
-$startTime = microtime(true);
-$focus = 0;
-$processed_tables = array(); // for keeping track of the tables we have worked on
-$empty = array();
-$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
- */
-installStatus($mod_strings['STAT_CREATE_DB']);
-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;
- //installStatus(sprintf($mod_strings['STAT_CREATE_DB_TABLE'], $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 (isset($dictionary[$focus->object_name]['table']) && $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()));
- } // end if()
-}
-
-
-installerHook('post_createAllModuleTables');
-
-//// 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
-$install_db_setup_messages[] = $mod_strings['LBL_PERFORM_CREATE_DEFAULT'];
-
-installStatus($mod_strings['STAT_CREATE_DEFAULT_SETTINGS']);
-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) {
- $install_db_setup_messages[] = $mod_strings['LBL_PERFORM_DEFAULT_USERS'];
- installLog($mod_strings['LBL_PERFORM_DEFAULT_USERS']);
- create_default_users();
- $install_db_setup_messages[] = $mod_strings['LBL_PERFORM_DEFAULT_DONE'];
-} else {
- $install_db_setup_messages[] = $mod_strings['LBL_PERFORM_ADMIN_PASSWORD'];
- 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);
- $install_db_setup_messages[] = $mod_strings['LBL_PERFORM_DONE'];
-}
-installerHook('post_createUsers');
-
-
-// default OOB schedulers
-
-$install_db_setup_messages[] = $mod_strings['LBL_PERFORM_DEFAULT_SCHEDULER'];
-installLog($mod_strings['LBL_PERFORM_DEFAULT_SCHEDULER']);
-$scheduler = BeanFactory::newBean('Schedulers');
-installerHook('pre_createDefaultSchedulers');
-$scheduler->rebuildDefaultSchedulers();
-installerHook('post_createDefaultSchedulers');
-$install_db_setup_messages[] = $mod_strings['LBL_PERFORM_DONE'];
-
-
-// Enable Sugar Feeds and add all feeds by default
-installLog("Enable SugarFeeds");
-enableSugarFeeds();
-
-// Install the logic hook for WorkFLow
-installLog("Creating WorkFlow logic hook");
-if (!function_exists('createWorkFlowLogicHook')) {
- function createWorkFlowLogicHook($filePath = 'Extension/application/Ext/LogicHooks/AOW_WorkFlow_Hook.php')
- {
- $customFileLoc = create_custom_directory($filePath);
- $fp = sugar_fopen($customFileLoc, 'wb');
- $contents = <<
- 'installer_locked' => false, --
{$mod_strings['LBL_DISABLED_DESCRIPTION_2']}
- -{$mod_strings['LBL_DISABLED_HELP_1']} {$mod_strings['LBL_DISABLED_HELP_2']}.
-EOQ; - $install_status_messages[] = $mod_strings['LBL_DISABLED_DESCRIPTION']; - } - $the_file = 'install/' . clean_string($the_file, 'FILE'); - - if (is_file($the_file)) { - installerHook('pre_installFileRequire', ['the_file' => $the_file]); - require($the_file); - $installResult = [ - 'success' => false, - 'messages' => $install_status_messages - ]; - return; - } - LoggerManager::getLogger()->fatal('Install file not found: ' . $the_file); - $installResult = [ - 'success' => false, - 'messages' => ['SuiteCRM Installation has been Disabled'] - ]; - return; -} - - -foreach ($installer_defaults as $key => $val) { - if (!isset($_SESSION[$key])) { - $_SESSION[$key] = $val; - } -} - -// always perform -clean_special_arguments(); -print_debug_comment(); -$next_clicked = false; -$next_step = 0; - -$workflow = array(); -// If less then recommended PHP version, insert old_php.pho into workflow. -if (check_php_version() === 0) { - $installResult = [ - 'success' => false, - 'messages' => ['PHP version not supported'] - ]; - return; -} -// use a simple array to map out the steps of the installer page flow -$workflow[] = 'welcome.php'; -$workflow[] = 'ready.php'; - -// TODO-g: remove these files.. -//'license.php', -//'installType.php', -//); -$workflow[] = 'installConfig.php'; -//$workflow[] = 'systemOptions.php'; -//$workflow[] = 'dbConfig_a.php'; -//$workflow[] = 'dbConfig_b.php'; - -//define web root, which will be used as default for site_url -if ($_SERVER['SERVER_PORT'] == '80') { - $web_root = $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']; -} else { - $web_root = $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['PHP_SELF']; -} -$web_root = str_replace("/install.php", "", $web_root); -$web_root = "http://$web_root"; - -if (!isset($_SESSION['oc_install']) || $_SESSION['oc_install'] == false) { - //$workflow[] = 'siteConfig_a.php'; - if (isset($_SESSION['install_type']) && !empty($_SESSION['install_type']) && - $_SESSION['install_type'] == 'custom') { - $workflow[] = 'siteConfig_b.php'; - } -} else { - if (is_readable('config.php')) { - require_once('config.php'); - } else { - $installResult = [ - 'success' => false, - 'messages' => ['Not able to read config.php'] - ]; - return; - } -} - -if (empty($sugar_config['cache_dir']) && !empty($_SESSION['cache_dir'])) { - $sugar_config['cache_dir'] = $_SESSION['cache_dir']; -} - -// set the form's php var to the loaded config's var else default to sane settings -if (!isset($_SESSION['setup_site_url']) || empty($_SESSION['setup_site_url'])) { - if (isset($sugar_config['site_url']) && !empty($sugar_config['site_url'])) { - $_SESSION['setup_site_url'] = $sugar_config['site_url']; - } else { - $_SESSION['setup_site_url'] = $web_root; - } -} - -if (!isset($_SESSION['setup_system_name']) || empty($_SESSION['setup_system_name'])) { - $_SESSION['setup_system_name'] = 'SugarCRM'; -} -if (!isset($_SESSION['setup_site_session_path']) || empty($_SESSION['setup_site_session_path'])) { - $_SESSION['setup_site_session_path'] = (isset($sugar_config['session_dir'])) ? $sugar_config['session_dir'] : ''; -} -if (!isset($_SESSION['setup_site_log_dir']) || empty($_SESSION['setup_site_log_dir'])) { - $_SESSION['setup_site_log_dir'] = (isset($sugar_config['log_dir'])) ? $sugar_config['log_dir'] : '.'; -} -if (!isset($_SESSION['setup_site_guid']) || empty($_SESSION['setup_site_guid'])) { - $_SESSION['setup_site_guid'] = (isset($sugar_config['unique_key'])) ? $sugar_config['unique_key'] : ''; -} -if (!isset($_SESSION['cache_dir']) || empty($_SESSION['cache_dir'])) { - $_SESSION['cache_dir'] = isset($sugar_config['cache_dir']) ? $sugar_config['cache_dir'] : 'cache/'; -} - -//$workflow[] = 'confirmSettings.php'; -$workflow[] = 'perform_setup_service.php'; -//$workflow[] = 'register.php'; -$workflow[] = 'complete_install.php'; - - -// increment/decrement the workflow pointer -$next_step = 9999; - -// Add check here to see if a silent install config file exists; if so then launch silent installer -if (!empty($sugar_config['installer_locked'])) { - $langHeader = get_language_header(); - $installResult = [ - 'success' => false, - 'messages' => ['Installer has been disabled'], - ]; - return; -} - -$validation_errors = array(); - -$the_file = 'SilentInstall'; - -$si_errors = false; -pullSilentInstallVarsIntoSession(); - -/* - * Make sure we are using the correct unique_key. The logic - * to save a custom unique_key happens lower in the process. - * However because of the initial FTS check we are already - * relying on this value which will not get reinitialized - * when we actual need it during index creation because - * SilentInstaller runs in one single process. - */ -if (!empty($_SESSION['setup_site_specify_guid']) && !empty($_SESSION['setup_site_guid'])) { - $sugar_config['unique_key'] = $_SESSION['setup_site_guid']; -} else { - $sugar_config['unique_key'] = md5(create_guid()); -} - -$validation_errors = validate_dbConfig(); -if ((is_countable($validation_errors) ? count($validation_errors) : 0) > 0) { - $the_file = 'dbConfig_a.php'; - $si_errors = true; -} -$validation_errors = validate_siteConfig('a'); -if ((is_countable($validation_errors) ? count($validation_errors) : 0) > 0) { - $the_file = 'siteConfig_a.php'; - $si_errors = true; -} -$validation_errors = validate_siteConfig('b'); -if ((is_countable($validation_errors) ? count($validation_errors) : 0) > 0) { - $the_file = 'siteConfig_b.php'; - $si_errors = true; -} - -if ($si_errors) { - $installResult = [ - 'success' => false, - 'messages' => $validation_errors, - ]; - return; -} - -require_once('jssource/minify.php'); -//since this is a SilentInstall we still need to make sure that -//the appropriate files are writable -// config.php -$result = make_writable('./config.php'); - -if (!$result) { - $installResult = [ - 'success' => false, - 'messages' => ['Not able to write to /public/legacy/config.php'], - ]; - return; -} - -// custom dir -$result = make_writable('./custom'); - -if (!$result) { - $installResult = [ - 'success' => false, - 'messages' => ['Not able to write to /public/legacy/custom'], - ]; - return; -} - - -// modules dir -$result = recursive_make_writable('./modules'); - -if (!$result) { - $installResult = [ - 'success' => false, - 'messages' => ['Not able to write to /public/legacy/modules'], - ]; - return; -} - -// cache dir -create_writable_dir(sugar_cached('custom_fields')); -create_writable_dir(sugar_cached('dyn_lay')); -create_writable_dir(sugar_cached('images')); -create_writable_dir(sugar_cached('modules')); -create_writable_dir(sugar_cached('layout')); -create_writable_dir(sugar_cached('pdf')); -create_writable_dir(sugar_cached('upload/import')); -create_writable_dir(sugar_cached('xml')); -create_writable_dir(sugar_cached('include/javascript')); -recursive_make_writable(sugar_cached('modules')); - -// public dir -$result = recursive_make_writable('./public'); -if (!$result) { - $installResult = [ - 'success' => false, - 'messages' => ['Not able to write to /public/legacy/public'], - ]; - return; -} - -// check whether we're getting this request from a command line tool -// we want to output brief messages if we're outputting to a command line tool -if (!empty($validation_errors)) { - $installResult = [ - 'success' => false, - 'messages' => $validation_errors - ]; - return; -} - - -$the_file = 'install/perform_setup_service.php'; - -if (is_file($the_file)) { - installerHook('pre_installFileRequire', ['the_file' => $the_file]); - $performSetupResult = []; - try { - require($the_file); - } catch (Exception $e) { - $installResult = [ - 'success' => false, - 'messages' => [$e->getMessage()] - ]; - return; - } - installerHook('post_installFileRequire', ['the_file' => $the_file]); - - if (isset($performSetupResult['success']) && $performSetupResult['success'] === false) { - $installResult = $performSetupResult; - return; - } - - $installResult = [ - 'success' => true, - 'messages' => [] - ]; - return; -} - -LoggerManager::getLogger()->fatal('Install file not found: ' . $the_file); -$installResult = [ - 'success' => false, - 'messages' => ['Install file not found: ' . $the_file] -]; -return; -