diff --git a/install/core/Installer.php b/install/core/Installer.php index d764e15e2a..b4987cf54e 100644 --- a/install/core/Installer.php +++ b/install/core/Installer.php @@ -148,7 +148,7 @@ class Installer */ public function saveData($database, $language) { - $initData = include('install/core/afterInstall/config.php'); + $initData = include('install/core/init/config.php'); $siteUrl = $this->getSystemHelper()->getBaseUrl(); @@ -194,7 +194,9 @@ class Installer if (isset($preferences['defaultCurrency']) && !in_array($preferences['defaultCurrency'], $currencyList)) { $preferences['currencyList'] = array($preferences['defaultCurrency']); - $preferences['baseCurrency'] = $preferences['defaultCurrency']; + + $preferences['currency'] = $this->getConfig()->get('currency'); + $preferences['currency']['base'] = $preferences['defaultCurrency']; } $res = $this->saveConfig($preferences); @@ -208,7 +210,7 @@ class Installer protected function createRecords() { - $records = include('install/core/afterInstall/records.php'); + $records = include('install/core/init/records.php'); $result = true; foreach ($records as $entityName => $recordList) { @@ -269,6 +271,8 @@ class Installer $result = $this->createRecord('User', $user); + $result &= $this->createRecords(); + return $result; } @@ -311,16 +315,9 @@ class Installer public function setSuccess() { - $this->auth(); - - /** afterInstall scripts */ - $result = $this->createRecords(); - $result &= $this->executeQueries(); - /** END: afterInstall scripts */ - $config = $this->app->getContainer()->get('config'); $config->set('isInstalled', true); - $result &= $config->save(); + $result = $config->save(); return $result; } @@ -382,21 +379,5 @@ class Installer return $this->getContainer()->get('scheduledJob')->getSetupMessage(); } - protected function executeQueries() - { - $queries = include('install/core/afterInstall/queries.php'); - - $pdo = $this->getEntityManager()->getPDO(); - - $result = true; - - foreach ($queries as $query) { - $sth = $pdo->prepare($query); - $result =& $sth->execute(); - } - - return $result; - } - } diff --git a/install/core/Language.php b/install/core/Language.php new file mode 100644 index 0000000000..8db1655272 --- /dev/null +++ b/install/core/Language.php @@ -0,0 +1,55 @@ +systemHelper = new SystemHelper(); + } + + protected function getSystemHelper() + { + return $this->systemHelper; + } + + public function get($language) + { + if (empty($language)) { + $language = $this->defaultLanguage; + } + + $langFileName = 'install/core/i18n/'.$language.'/install.json'; + if (!file_exists($langFileName)) { + $langFileName = 'install/core/i18n/'.$this->defaultLanguage.'/install.json'; + } + + $i18n = file_get_contents($langFileName); + $i18n = json_decode($i18n, true); + + $this->afterRetrieve($i18n); + + return $i18n; + } + + /** + * After retrieve actions + * + * @param array $i18n + * @return array $i18n + */ + protected function afterRetrieve(array &$i18n) + { + /** Get rewrite rules */ + $serverType = $this->getSystemHelper()->getServerType(); + $rewriteRules = $this->getSystemHelper()->getRewriteRules(); + $i18n['options']['modRewriteHelp'][$serverType] = str_replace('{0}', $rewriteRules, $i18n['options']['modRewriteHelp'][$serverType]); + } + + +} diff --git a/install/core/SystemHelper.php b/install/core/SystemHelper.php index 92f0587e49..391a34b2e5 100644 --- a/install/core/SystemHelper.php +++ b/install/core/SystemHelper.php @@ -76,7 +76,7 @@ class SystemHelper extends \Espo\Core\Utils\System return $result; } - public function checkDbConnection($hostName, $port, $dbUserName, $dbUserPass, $dbName, $dbDriver = 'pdo_mysql', $isCreateDatabase = true) + public function checkDbConnection($hostName, $port ,$dbUserName, $dbUserPass, $dbName, $dbDriver = 'pdo_mysql') { $result['success'] = true; @@ -104,28 +104,6 @@ class SystemHelper extends \Espo\Core\Utils\System $result['errors']['dbConnect']['errorMsg'] = $e->getMessage(); $result['success'] = false; } - - /** try to create a database */ - if ($isCreateDatabase && !$result['success'] && $result['errors']['dbConnect']['errorCode'] == '1049') { - - $dsn = "mysql:host={$hostName};" . ((!empty($port)) ? "port={$port}" : ''); - $pdo = new PDO($dsn, $dbUserName, $dbUserPass); - - $isCreated = true; - try { - $pdo->query("CREATE DATABASE IF NOT EXISTS `$dbName`"); - } catch (PDOException $e) { - $isCreated = false; - } - - if ($isCreated) { - return $this->checkDbConnection($hostName, $port, $dbUserName, $dbUserPass, $dbName, $dbDriver, false); - } - } - /** END: try to create a database */ - - - break; } @@ -207,8 +185,8 @@ class SystemHelper extends \Espo\Core\Utils\System $commands[] = $this->getCd(); } - $commands[] = 'find '.$path.' -type f -exec ' .$sudoStr.'chmod '.$bufPerm[0].' {} +';//.'chmod '.$bufPerm[0].' $(find '.$path.' -type f)'; - $commands[] = 'find '.$path.' -type d -exec ' .$sudoStr. 'chmod '.$bufPerm[1].' {} +';//.'chmod '.$bufPerm[1].' $(find '.$path.' -type d)'; + $commands[] = 'find '.$path.' -type f -exec ' .$sudoStr.'chmod '.$bufPerm[0].' {} +'; + $commands[] = 'find '.$path.' -type d -exec ' .$sudoStr. 'chmod '.$bufPerm[1].' {} +'; if (count($permissions) >= 2) { return implode(' ' . $this->combineOperator . ' ', $commands); @@ -273,4 +251,19 @@ class SystemHelper extends \Espo\Core\Utils\System return $cd; } + public function getRewriteRules() + { + $serverType = $this->getServerType(); + + $rules = array( + 'nginx' => "location /api/v1/ {\n if (!-e " . '$request_filename' . "){\n rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n }\n}\n\nlocation / {\n rewrite reset/?$ reset.html break;\n}\n\nlocation /(data|api) {\n if (-e " . '$request_filename' . "){\n return 403;\n }\n}\n\nlocation /data/logs {\n return 403;\n}\nlocation /data/config.php$ {\n return 403;\n}\nlocation /data/cache {\n return 403;\n}\nlocation /data/upload {\n return 403;\n}\nlocation /application {\n return 403;\n}\nlocation /custom {\n return 403;\n}\nlocation /vendor {\n return 403;\n}", + ); + + if (isset($rules[$serverType])) { + return $rules[$serverType]; + } + + return ''; + } + } diff --git a/install/core/i18n/de_DE/install.json b/install/core/i18n/de_DE/install.json index 2084e646c8..08ae567549 100644 --- a/install/core/i18n/de_DE/install.json +++ b/install/core/i18n/de_DE/install.json @@ -104,7 +104,7 @@ }, "modRewriteHelp": { "apache": "API Fehler: EspoCRM API nicht verfügbar
Mögliches Problem: deaktiviertes \"mod_rewrite\" des Apache Servers oder des .htaccess Supports.", - "nginx": "API Error: EspoCRM API unavailable.
Add this code to Nginx Host Config (inside \"server\" block):
\n
\nlocation /api/v1/ {\n    if (!-e $request_filename){\n        rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n    }\n}\n\nlocation / {\n    rewrite reset/?$ reset.html break;\n}
", + "nginx": "API Error: EspoCRM API unavailable.
Add this code to your Nginx Host Config (inside \"server\" block):
\n
\n{0}\n
", "microsoft-iis": "API Fehler: EspoCRM API nicht verfügbar
Mögliches Problem: deaktiviertes \"URL Rewrite\". Bitte überprüfen und aktivieren Sie das \"URL Rewrite\" Modul im IIS Server.", "default": "API Error: EspoCRM API unavailable.
Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support." } diff --git a/install/core/i18n/en_US/install.json b/install/core/i18n/en_US/install.json index 953f68d12e..9472badbf3 100644 --- a/install/core/i18n/en_US/install.json +++ b/install/core/i18n/en_US/install.json @@ -104,7 +104,7 @@ }, "modRewriteHelp": { "apache": "API Error: EspoCRM API unavailable.
Possible problems: disabled \"mod_rewrite\" in Apache server or .htaccess support.", - "nginx": "API Error: EspoCRM API unavailable.
Add this code to Nginx Host Config (inside \"server\" block):
\n
\nlocation /api/v1/ {\n    if (!-e $request_filename){\n        rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n    }\n}\n\nlocation / {\n    rewrite reset/?$ reset.html break;\n}
", + "nginx": "API Error: EspoCRM API unavailable.
Add this code to your Nginx Host Config (inside \"server\" block):
\n
\n{0}\n
", "microsoft-iis": "API Error: EspoCRM API unavailable.
Possible problem: disabled \"URL Rewrite\". Please check and enable \"URL Rewrite\" Module in IIS server", "default": "API Error: EspoCRM API unavailable.
Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support." } diff --git a/install/core/i18n/es_ES/install.json b/install/core/i18n/es_ES/install.json index f7c323bdfa..1d6be88417 100644 --- a/install/core/i18n/es_ES/install.json +++ b/install/core/i18n/es_ES/install.json @@ -103,7 +103,7 @@ }, "modRewriteHelp": { "apache": "API Error: EspoCRM API unavailable.
Possible problems: disabled \"mod_rewrite\" in Apache server or .htaccess support.", - "nginx": "API Error: EspoCRM API unavailable.
Add this code to Nginx Host Config (inside \"server\" block):
\n
\nlocation /api/v1/ {\n    if (!-e $request_filename){\n        rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n    }\n}\n\nlocation / {\n    rewrite reset/?$ reset.html break;\n}
", + "nginx": "API Error: EspoCRM API unavailable.
Add this code to your Nginx Host Config (inside \"server\" block):
\n
\n{0}\n
", "microsoft-iis": "API Error: EspoCRM API unavailable.
Possible problem: disabled \"URL Rewrite\". Please check and enable \"URL Rewrite\" Module in IIS server", "default": "API Error: EspoCRM API unavailable.
Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support." } diff --git a/install/core/i18n/fr_FR/install.json b/install/core/i18n/fr_FR/install.json index 3dc29a7038..c9da6be879 100644 --- a/install/core/i18n/fr_FR/install.json +++ b/install/core/i18n/fr_FR/install.json @@ -104,7 +104,7 @@ }, "modRewriteHelp": { "apache": "API Error: EspoCRM API unavailable.
Possible problems: disabled \"mod_rewrite\" in Apache server or .htaccess support.", - "nginx": "API Error: EspoCRM API unavailable.
Add this code to Nginx Host Config (inside \"server\" block):
\n
\nlocation /api/v1/ {\n    if (!-e $request_filename){\n        rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n    }\n}\n\nlocation / {\n    rewrite reset/?$ reset.html break;\n}
", + "nginx": "API Error: EspoCRM API unavailable.
Add this code to your Nginx Host Config (inside \"server\" block):
\n
\n{0}\n
", "microsoft-iis": "API Error: EspoCRM API unavailable.
Possible problem: disabled \"URL Rewrite\". Please check and enable \"URL Rewrite\" Module in IIS server", "default": "API Error: EspoCRM API unavailable.
Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support." } diff --git a/install/core/i18n/nl_NL/install.json b/install/core/i18n/nl_NL/install.json index 9871400d1d..e288909327 100644 --- a/install/core/i18n/nl_NL/install.json +++ b/install/core/i18n/nl_NL/install.json @@ -104,7 +104,7 @@ }, "modRewriteHelp": { "apache": "API Error: EspoCRM API niet beschikbaar.
Mogelijke Oorzaak: disabled \"mod_rewrite\" in Apache server of .htaccess ondersteuning.", - "nginx": "API Error: EspoCRM API unavailable.
Add this code to Nginx Host Config (inside \"server\" block):
\n
\nlocation /api/v1/ {\n    if (!-e $request_filename){\n        rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n    }\n}\n\nlocation / {\n    rewrite reset/?$ reset.html break;\n}
", + "nginx": "API Error: EspoCRM API unavailable.
Add this code to your Nginx Host Config (inside \"server\" block):
\n
\n{0}\n
", "microsoft-iis": "API Error: EspoCRM API niet beschikbaar.
Mogelijk probleem: disabled \"URL Rewrite\". Controleer en activeer \"URL Rewrite\" Module in IIS server", "default": "API Error: EspoCRM API unavailable.
Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support." } diff --git a/install/core/i18n/ro_RO/install.json b/install/core/i18n/ro_RO/install.json index caae6b4c29..942c6ae1a5 100644 --- a/install/core/i18n/ro_RO/install.json +++ b/install/core/i18n/ro_RO/install.json @@ -104,7 +104,7 @@ }, "modRewriteHelp": { "apache": "Eroare API: API-ul EspoCRM nu este valabil.
Probleme posibile: este dezactivat \"mod_rewrite\" in server-ul Apache, sau in .htaccess.", - "nginx": "API Error: EspoCRM API unavailable.
Add this code to Nginx Host Config (inside \"server\" block):
\n
\nlocation /api/v1/ {\n    if (!-e $request_filename){\n        rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n    }\n}\n\nlocation / {\n    rewrite reset/?$ reset.html break;\n}
", + "nginx": "API Error: EspoCRM API unavailable.
Add this code to your Nginx Host Config (inside \"server\" block):
\n
\n{0}\n
", "microsoft-iis": "Eroare API: API-ul EspoCRM nu este valabil.
Probleme posibile: este dezactivat \"URL Rewrite\". Verificati si activati modulul \"URL Rewrite\" in server-ul IIS", "default": "API Error: EspoCRM API unavailable.
Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support." } diff --git a/install/core/i18n/tr_TR/install.json b/install/core/i18n/tr_TR/install.json index a08075de96..74b36e5ca9 100644 --- a/install/core/i18n/tr_TR/install.json +++ b/install/core/i18n/tr_TR/install.json @@ -103,7 +103,7 @@ }, "modRewriteHelp": { "apache": "API Error: EspoCRM API unavailable.
Possible problems: disabled \"mod_rewrite\" in Apache server or .htaccess support.", - "nginx": "API Error: EspoCRM API unavailable.
Add this code to Nginx Host Config (inside \"server\" block):
\n
\nlocation \/api\/v1\/ {\n    if (!-e $request_filename){\n        rewrite ^\/api\/v1\/(.*)$ \/api\/v1\/index.php last; break;\n    }\n}\n\nlocation \/ {\n    rewrite reset\/?$ reset.html break;\n}<\/pre>",
+			"nginx": "API Error: EspoCRM API unavailable.
Add this code to your Nginx Host Config (inside \"server\" block):
\n
\n{0}\n
", "microsoft-iis": "API Error: EspoCRM API unavailable.
Possible problem: disabled \"URL Rewrite\". Please check and enable \"URL Rewrite\" Module in IIS server", "default": "API Error: EspoCRM API unavailable.
Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support." } diff --git a/install/core/i18n/vi_VN/install.json b/install/core/i18n/vi_VN/install.json index bcffaaedf5..4c6eebbc3b 100644 --- a/install/core/i18n/vi_VN/install.json +++ b/install/core/i18n/vi_VN/install.json @@ -104,7 +104,7 @@ }, "modRewriteHelp": { "apache": "API Error: EspoCRM API unavailable.
Possible problems: disabled \"mod_rewrite\" in Apache server or .htaccess support.", - "nginx": "API Error: EspoCRM API unavailable.
Add this code to Nginx Host Config (inside \"server\" block):
\n
\nlocation /api/v1/ {\n    if (!-e $request_filename){\n        rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;\n    }\n}\n\nlocation / {\n    rewrite reset/?$ reset.html break;\n}
", + "nginx": "API Error: EspoCRM API unavailable.
Add this code to your Nginx Host Config (inside \"server\" block):
\n
\n{0}\n
", "microsoft-iis": "API Error: EspoCRM API unavailable.
Possible problem: disabled \"URL Rewrite\". Please check and enable \"URL Rewrite\" Module in IIS server", "default": "API Error: EspoCRM API unavailable.
Possible problem: disabled Rewrite Module. Please check and enable Rewrite Module in your server (e.g. mod_rewrite in Apache) and .htaccess support." } diff --git a/install/core/tpl/step2.tpl b/install/core/tpl/step2.tpl index ff0dab0b9a..3139e959f4 100644 --- a/install/core/tpl/step2.tpl +++ b/install/core/tpl/step2.tpl @@ -2,9 +2,9 @@

{$langs['labels']['Step2 page title']}

- +
-
+
- - - + + +
+
-
+
@@ -60,8 +61,8 @@
-
- +
+