Added config file for installation
This commit is contained in:
+2
-1
@@ -15,4 +15,5 @@ npm-debug.log
|
||||
/tests/integration/config.php
|
||||
composer.phar
|
||||
vendor/
|
||||
/custom/Espo/Custom/*
|
||||
/custom/Espo/Custom/*
|
||||
/install/config.php
|
||||
@@ -41,6 +41,8 @@ class Installer
|
||||
|
||||
protected $databaseHelper = null;
|
||||
|
||||
protected $installerConfig;
|
||||
|
||||
protected $isAuth = false;
|
||||
|
||||
protected $permissionMap;
|
||||
@@ -71,6 +73,9 @@ class Installer
|
||||
$user = $this->getEntityManager()->getEntity('User');
|
||||
$this->app->getContainer()->setUser($user);
|
||||
|
||||
require_once('install/core/InstallerConfig.php');
|
||||
$this->installerConfig = new InstallerConfig();
|
||||
|
||||
require_once('install/core/SystemHelper.php');
|
||||
$this->systemHelper = new SystemHelper();
|
||||
|
||||
@@ -127,6 +132,11 @@ class Installer
|
||||
return $this->databaseHelper;
|
||||
}
|
||||
|
||||
protected function getInstallerConfig()
|
||||
{
|
||||
return $this->installerConfig;
|
||||
}
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->app->getContainer()->get('fileManager');
|
||||
@@ -161,6 +171,12 @@ class Installer
|
||||
|
||||
public function isInstalled()
|
||||
{
|
||||
$installerConfig = $this->getInstallerConfig();
|
||||
|
||||
if ($installerConfig->get('isInstalled')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->app->isInstalled();
|
||||
}
|
||||
|
||||
@@ -184,6 +200,11 @@ class Installer
|
||||
return $translated;
|
||||
}
|
||||
|
||||
public function getInstallerConfigData()
|
||||
{
|
||||
return $this->getInstallerConfig()->getAllData();
|
||||
}
|
||||
|
||||
public function getSystemRequirementList($type, $requiredOnly = false, array $additionalData = null)
|
||||
{
|
||||
$systemRequirementManager = new \Espo\Core\Utils\SystemRequirements($this->app->getContainer());
|
||||
@@ -419,6 +440,10 @@ class Installer
|
||||
$result &= $this->executeQueries();
|
||||
/** END: afterInstall scripts */
|
||||
|
||||
$installerConfig = $this->getInstallerConfig();
|
||||
$installerConfig->set('isInstalled', true);
|
||||
$installerConfig->save();
|
||||
|
||||
$config = $this->app->getContainer()->get('config');
|
||||
$config->set('isInstalled', true);
|
||||
$result &= $config->save();
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2019 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
class InstallerConfig
|
||||
{
|
||||
private $data;
|
||||
|
||||
private $fileManager;
|
||||
|
||||
protected $configPath = 'install/config.php'; //full path: install/config.php
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fileManager = new \Espo\Core\Utils\File\Manager();
|
||||
}
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->fileManager;
|
||||
}
|
||||
|
||||
protected function getContainer()
|
||||
{
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
protected function loadData()
|
||||
{
|
||||
if (file_exists($this->configPath)) {
|
||||
$data = include($this->configPath);
|
||||
if (is_array($data)) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getAllData()
|
||||
{
|
||||
if (!$this->data) {
|
||||
$this->data = $this->loadData();
|
||||
}
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function get($name, $default = [])
|
||||
{
|
||||
if (!$this->data) {
|
||||
$this->data = $this->loadData();
|
||||
}
|
||||
|
||||
if (array_key_exists($name, $this->data)) {
|
||||
return $this->data[$name];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function set($name, $value = null)
|
||||
{
|
||||
if (!is_array($name)) {
|
||||
$name = array($name => $value);
|
||||
}
|
||||
|
||||
foreach ($name as $key => $value) {
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$data = $this->loadData();
|
||||
|
||||
if (is_array($this->data)) {
|
||||
foreach ($this->data as $key => $value) {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->getFileManager()->putPhpContents($this->configPath, $data);
|
||||
|
||||
if ($result) {
|
||||
$this->data = null;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
+9
-4
@@ -86,17 +86,21 @@ $installer = new Installer();
|
||||
|
||||
// check if app was installed
|
||||
if ($installer->isInstalled() && !isset($_SESSION['install']['installProcess'])) {
|
||||
if (isset($_SESSION['install']['redirected']) && $_SESSION['install']['redirected']) {
|
||||
die('The installation is disabled. It can be enabled in config files.');
|
||||
}
|
||||
|
||||
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
||||
$url = preg_replace('/install\/?/', '', $url, 1);
|
||||
$url = strtok($url, '#');
|
||||
$url = strtok($url, '?');
|
||||
|
||||
$_SESSION['install']['redirected'] = true;
|
||||
header("Location: {$url}");
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
// double check if infinite loop
|
||||
$_SESSION['install']['installProcess'] = true;
|
||||
}
|
||||
|
||||
$_SESSION['install']['installProcess'] = true;
|
||||
|
||||
$smarty->caching = false;
|
||||
$smarty->setTemplateDir('install/core/tpl');
|
||||
@@ -142,6 +146,7 @@ $smarty->assign('action', ucfirst($action));
|
||||
|
||||
/** config */
|
||||
$smarty->assign('config', $config);
|
||||
$smarty->assign('installerConfig', $installer->getInstallerConfigData());
|
||||
|
||||
if (Utils::checkActionExists($action)) {
|
||||
include $actionFile;
|
||||
|
||||
Reference in New Issue
Block a user