Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend
This commit is contained in:
@@ -133,7 +133,7 @@ class Application
|
||||
{
|
||||
$config = $this->getContainer()->get('config');
|
||||
|
||||
if (file_exists($config->get('configPath')) && $config->get('isInstalled')) {
|
||||
if (file_exists($config->getConfigPath()) && $config->get('isInstalled')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ class DataManager
|
||||
{
|
||||
private $container;
|
||||
|
||||
private $cachePath = 'data/cache';
|
||||
|
||||
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
@@ -59,9 +62,7 @@ class DataManager
|
||||
*/
|
||||
public function clearCache()
|
||||
{
|
||||
$cacheDir = $this->getContainer()->get('config')->get('cachePath');
|
||||
|
||||
$result = $this->getContainer()->get('fileManager')->removeInDir($cacheDir);
|
||||
$result = $this->getContainer()->get('fileManager')->removeInDir($this->cachePath);
|
||||
|
||||
if ($result === false) {
|
||||
throw new Exceptions\Error("Error while clearing cache");
|
||||
|
||||
@@ -32,6 +32,8 @@ class Config
|
||||
*/
|
||||
private $defaultConfigPath = 'application/Espo/Core/defaults/config.php';
|
||||
|
||||
protected $configPath = 'data/config.php';
|
||||
|
||||
/**
|
||||
* Array of admin items
|
||||
*
|
||||
@@ -62,6 +64,11 @@ class Config
|
||||
return $this->fileManager;
|
||||
}
|
||||
|
||||
public function getConfigPath()
|
||||
{
|
||||
return $this->configPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option from config
|
||||
*
|
||||
@@ -85,7 +92,6 @@ class Config
|
||||
return $lastBranch;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set an option to the config
|
||||
*
|
||||
@@ -95,15 +101,11 @@ class Config
|
||||
*/
|
||||
public function set($name, $value = '')
|
||||
{
|
||||
if (is_array($name)) {
|
||||
return $this->setArray($name);
|
||||
if (!is_array($name)) {
|
||||
$name = array($name => $value);
|
||||
}
|
||||
|
||||
$content = array($name => $value);
|
||||
$status = $this->getFileManager()->mergeContentsPHP($this->get('configPath'), $content, true);
|
||||
$this->loadConfig(true);
|
||||
|
||||
return $status;
|
||||
return $this->setArray($name);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,10 +121,15 @@ class Config
|
||||
return false;
|
||||
}
|
||||
|
||||
$status = $this->getFileManager()->mergeContentsPHP($this->get('configPath'), $values, true);
|
||||
$result = $this->getFileManager()->mergeContentsPHP($this->configPath, $values, true);
|
||||
$this->loadConfig(true);
|
||||
|
||||
return $status;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getDefaults()
|
||||
{
|
||||
return $this->getFileManager()->getContents($this->defaultConfigPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,20 +143,9 @@ class Config
|
||||
return $this->configData;
|
||||
}
|
||||
|
||||
$defaultConfig = $this->getFileManager()->getContents($this->defaultConfigPath);
|
||||
$configPath = file_exists($this->configPath) ? $this->configPath : $this->defaultConfigPath;
|
||||
|
||||
$config = $this->getFileManager()->getContents($defaultConfig['configPath']);
|
||||
if (empty($config)) {
|
||||
$config = array();
|
||||
}
|
||||
|
||||
if (!empty($defaultConfig['rewriteOptions'])) {
|
||||
$this->configData = Util::merge((array) $defaultConfig, (array) $config, 1, $defaultConfig['rewriteOptions']);
|
||||
} else {
|
||||
$this->configData = Util::merge((array) $defaultConfig, (array) $config);
|
||||
}
|
||||
|
||||
$this->adminItems = $this->getRestrictItems();
|
||||
$this->configData = $this->getFileManager()->getContents($configPath);
|
||||
|
||||
return $this->configData;
|
||||
}
|
||||
@@ -161,7 +157,7 @@ class Config
|
||||
* @param $isAdmin
|
||||
* @return array
|
||||
*/
|
||||
public function getData($isAdmin=false)
|
||||
public function getData($isAdmin = false)
|
||||
{
|
||||
$configData = $this->loadConfig();
|
||||
|
||||
@@ -182,7 +178,7 @@ class Config
|
||||
* @param $isAdmin
|
||||
* @return bool
|
||||
*/
|
||||
public function setData($data, $isAdmin=false)
|
||||
public function setData($data, $isAdmin = false)
|
||||
{
|
||||
$restrictItems = $this->getRestrictItems($isAdmin);
|
||||
|
||||
@@ -224,7 +220,7 @@ class Config
|
||||
* @param $isAdmin
|
||||
* @return bool
|
||||
*/
|
||||
protected function isAllowed($name, $isAdmin=false)
|
||||
protected function isAllowed($name, $isAdmin = false)
|
||||
{
|
||||
if (in_array($name, $this->getRestrictItems($isAdmin))) {
|
||||
return false;
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
************************************************************************/
|
||||
|
||||
return array (
|
||||
'configPath' => 'data/config.php',
|
||||
'cachePath' => 'data/cache',
|
||||
|
||||
'database' =>
|
||||
array (
|
||||
'driver' => 'pdo_mysql',
|
||||
'host' => 'localhost',
|
||||
'dbname' => '',
|
||||
'user' => '',
|
||||
'password' => '',
|
||||
),
|
||||
'useCache' => true,
|
||||
'recordsPerPage' => 20,
|
||||
@@ -44,6 +44,12 @@ return array (
|
||||
array (
|
||||
),
|
||||
'defaultCurrency' => 'USD',
|
||||
'currency' =>
|
||||
array(
|
||||
'base' => 'USD',
|
||||
'rate' => array(
|
||||
),
|
||||
),
|
||||
'outboundEmailIsShared' => true,
|
||||
'outboundEmailFromName' => 'EspoCRM',
|
||||
'outboundEmailFromAddress' => '',
|
||||
@@ -60,9 +66,9 @@ return array (
|
||||
'logger' =>
|
||||
array (
|
||||
'path' => 'data/logs/espo.log',
|
||||
'level' => 'ERROR', /*DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY*/
|
||||
'isRotate' => true, /*rotate every day every logs files*/
|
||||
'maxRotateFiles' => 30, /*max number of rotate files*/
|
||||
'level' => 'ERROR', /** DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY */
|
||||
'isRotate' => true, /** rotate log files every day */
|
||||
'maxRotateFiles' => 30, /** max number of rotate files */
|
||||
),
|
||||
'defaultPermissions' =>
|
||||
array (
|
||||
@@ -72,16 +78,9 @@ return array (
|
||||
'group' => '',
|
||||
),
|
||||
'cron' => array(
|
||||
'maxJobNumber' => 15, /*Max number of jobs per one execution*/
|
||||
'jobPeriod' => 7800, /*Period for jobs, ex. if cron executed at 15:35, it will execute all pending jobs for times from 14:05 to 15:35*/
|
||||
'minExecutionTime' => 50, /*to avoid too frequency execution*/
|
||||
),
|
||||
'currency' =>
|
||||
array(
|
||||
'base' => 'USD',
|
||||
'rate' => array(
|
||||
'EUR' => 1.37,
|
||||
),
|
||||
'maxJobNumber' => 15, /** Max number of jobs per one execution */
|
||||
'jobPeriod' => 7800, /** Period for jobs, ex. if cron executed at 15:35, it will execute all pending jobs for times from 14:05 to 15:35 */
|
||||
'minExecutionTime' => 50, /** to avoid too frequency execution **/
|
||||
),
|
||||
'globalSearchEntityList' =>
|
||||
array (
|
||||
@@ -91,6 +90,8 @@ return array (
|
||||
3 => 'Prospect',
|
||||
4 => 'Opportunity',
|
||||
),
|
||||
"tabList" => array("Account", "Contact", "Lead", "Opportunity", "Calendar", "Meeting", "Call", "Task", "Case", "Prospect", "Email"),
|
||||
"quickCreateList" => array("Account", "Contact", "Lead", "Opportunity", "Meeting", "Call", "Task", "Case", "Prospect"),
|
||||
'crud' => array(
|
||||
'get' => 'read',
|
||||
'post' => 'create',
|
||||
@@ -116,7 +117,6 @@ return array (
|
||||
'isInstalled',
|
||||
'defaultPermissions',
|
||||
'systemUser',
|
||||
'rewriteOptions',
|
||||
),
|
||||
'adminItems' =>
|
||||
array (
|
||||
@@ -132,14 +132,6 @@ return array (
|
||||
'smtpPassword',
|
||||
'cron',
|
||||
),
|
||||
'rewriteOptions' =>
|
||||
array (
|
||||
'tabList',
|
||||
'quickCreateList',
|
||||
'globalSearchEntityList',
|
||||
),
|
||||
"tabList" => array("Account", "Contact", "Lead", "Opportunity", "Calendar", "Meeting", "Call", "Task", "Case", "Prospect", "Email"),
|
||||
"quickCreateList" => array("Account", "Contact", "Lead", "Opportunity", "Meeting", "Call", "Task", "Case", "Prospect"),
|
||||
'isInstalled' => false,
|
||||
);
|
||||
|
||||
|
||||
@@ -66,13 +66,20 @@ class Installer
|
||||
public function __construct()
|
||||
{
|
||||
$this->app = new \Espo\Core\Application();
|
||||
$this->writableList[] = $this->app->getContainer()->get('config')->get('configPath');
|
||||
|
||||
$user = $this->getEntityManager()->getEntity('User');
|
||||
$this->app->getContainer()->setUser($user);
|
||||
|
||||
require_once('install/core/SystemHelper.php');
|
||||
$this->systemHelper = new SystemHelper();
|
||||
|
||||
$configPath = $this->getConfig()->getConfigPath();
|
||||
$this->writableList[] = $configPath;
|
||||
|
||||
if (!file_exists($configPath)) {
|
||||
$configData = $this->getConfig()->getDefaults();
|
||||
$this->getConfig()->set($configData);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getContainer()
|
||||
@@ -85,6 +92,11 @@ class Installer
|
||||
return $this->getContainer()->get('entityManager');
|
||||
}
|
||||
|
||||
protected function getConfig()
|
||||
{
|
||||
return $this->app->getContainer()->get('config');
|
||||
}
|
||||
|
||||
protected function getSystemHelper()
|
||||
{
|
||||
return $this->systemHelper;
|
||||
@@ -191,9 +203,13 @@ class Installer
|
||||
|
||||
public function setPreferences($preferences)
|
||||
{
|
||||
$currencyList = $this->app->getContainer()->get('config')->get('currencyList');
|
||||
$currencyList = $this->getConfig()->get('currencyList');
|
||||
if (isset($preferences['defaultCurrency']) && !in_array($preferences['defaultCurrency'], $currencyList)) {
|
||||
|
||||
$preferences['currencyList'] = array($preferences['defaultCurrency']);
|
||||
|
||||
$preferences['currency'] = $this->getConfig()->get('currency');
|
||||
$preferences['currency']['base'] = $preferences['defaultCurrency'];
|
||||
}
|
||||
|
||||
$res = $this->saveConfig($preferences);
|
||||
|
||||
@@ -8,19 +8,19 @@ use tests\ReflectionHelper;
|
||||
class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $object;
|
||||
|
||||
|
||||
protected $objects;
|
||||
|
||||
protected $defaultConfigPath = 'tests/testData/Utils/Config/defaultConfig.php';
|
||||
protected $configPath = 'tests/testData/Utils/Config/config.php';
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->objects['fileManager'] = new \Espo\Core\Utils\File\Manager();
|
||||
{
|
||||
$this->objects['fileManager'] = new \Espo\Core\Utils\File\Manager();
|
||||
|
||||
$this->object = new \Espo\Core\Utils\Config($this->objects['fileManager']);
|
||||
|
||||
$this->reflection = new ReflectionHelper($this->object);
|
||||
$this->reflection->setProperty('defaultConfigPath', $this->defaultConfigPath);
|
||||
$this->reflection = new ReflectionHelper($this->object);
|
||||
$this->reflection->setProperty('configPath', $this->configPath);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
@@ -30,7 +30,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
|
||||
function testLoadConfig()
|
||||
{
|
||||
{
|
||||
$this->assertArrayHasKey('database', $this->reflection->invokeMethod('loadConfig', array()));
|
||||
|
||||
$this->assertArrayHasKey('dateFormat', $this->reflection->invokeMethod('loadConfig', array()));
|
||||
@@ -39,7 +39,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||
function testGet()
|
||||
{
|
||||
$result = array(
|
||||
'driver' => 'mysqli',
|
||||
'driver' => 'pdo_mysql',
|
||||
'host' => 'localhost',
|
||||
'dbname' => 'espocrm',
|
||||
'user' => 'root',
|
||||
@@ -47,14 +47,16 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
$this->assertEquals($result, $this->object->get('database'));
|
||||
|
||||
$result = 'mysqli';
|
||||
$result = 'pdo_mysql';
|
||||
$this->assertEquals($result, $this->object->get('database.driver'));
|
||||
|
||||
|
||||
$result = 'MM/DD/YYYY';
|
||||
$result = 'YYYY-MM-DD';
|
||||
$this->assertEquals($result, $this->object->get('dateFormat'));
|
||||
|
||||
$this->assertTrue($this->object->get('isInstalled'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function testSet()
|
||||
{
|
||||
@@ -69,12 +71,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
function testSetArray()
|
||||
{
|
||||
$this->reflection->setProperty('defaultConfigPath', 'tests/testData/Utils/Config/defaultConfigArray.php');
|
||||
|
||||
$values = array(
|
||||
'testOption' => 'Test',
|
||||
'testOption2' => 'Test2',
|
||||
);
|
||||
'testOption2' => 'Test2',
|
||||
);
|
||||
|
||||
$this->assertTrue($this->object->set($values));
|
||||
$this->assertEquals('Test', $this->object->get('testOption'));
|
||||
@@ -84,8 +84,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||
'testOption' => 'Another Wrong Value',
|
||||
);
|
||||
$this->assertTrue($this->object->set($wrongArray));
|
||||
|
||||
$this->reflection->setProperty('defaultConfigPath', $this->defaultConfigPath);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,26 +3,21 @@
|
||||
return array (
|
||||
'database' =>
|
||||
array (
|
||||
'driver' => 'mysqli',
|
||||
'driver' => 'pdo_mysql',
|
||||
'host' => 'localhost',
|
||||
'dbname' => 'espocrm',
|
||||
'user' => 'root',
|
||||
'password' => '',
|
||||
),
|
||||
'logger' =>
|
||||
array (
|
||||
'dir' => 'data/logs',
|
||||
'file' => 'espo.log',
|
||||
'level' => 'DEBUG',
|
||||
),
|
||||
'useCache' => false,
|
||||
'recordsPerPage' => 20,
|
||||
'recordsPerPageSmall' => 5,
|
||||
'applicationName' => 'EspoCRM',
|
||||
'timeZone' => '',
|
||||
'dateFormat' => 'MM/DD/YYYY',
|
||||
'version' => '1.0',
|
||||
'timeZone' => 'UTC',
|
||||
'dateFormat' => 'YYYY-MM-DD',
|
||||
'timeFormat' => 'HH:mm',
|
||||
'weekStart' => '1',
|
||||
'weekStart' => 1,
|
||||
'thousandSeparator' => ',',
|
||||
'decimalMark' => '.',
|
||||
'currencyList' =>
|
||||
@@ -30,6 +25,126 @@ return array (
|
||||
0 => 'USD',
|
||||
1 => 'EUR',
|
||||
),
|
||||
'defaultCurrency' => 'USD',
|
||||
'currency' =>
|
||||
array (
|
||||
'base' => 'USD',
|
||||
'rate' =>
|
||||
array (
|
||||
'EUR' => '1.37',
|
||||
),
|
||||
),
|
||||
'outboundEmailIsShared' => true,
|
||||
'outboundEmailFromName' => 'EspoCRM',
|
||||
'outboundEmailFromAddress' => '',
|
||||
'smtpServer' => '',
|
||||
'smtpPort' => 25,
|
||||
'smtpAuth' => true,
|
||||
'smtpSecurity' => '',
|
||||
'smtpUsername' => '',
|
||||
'smtpPassword' => '',
|
||||
'languageList' =>
|
||||
array (
|
||||
0 => 'en_US',
|
||||
),
|
||||
'language' => 'en_US',
|
||||
'logger' =>
|
||||
array (
|
||||
'path' => 'data/logs/espo.log',
|
||||
'level' => 'INFO',
|
||||
'isRotate' => true,
|
||||
'maxRotateFiles' => 5,
|
||||
),
|
||||
'defaultPermissions' =>
|
||||
array (
|
||||
'dir' => '0775',
|
||||
'file' => '0664',
|
||||
'user' => '',
|
||||
'group' => '',
|
||||
),
|
||||
'cron' =>
|
||||
array (
|
||||
'maxJobNumber' => 15,
|
||||
'jobPeriod' => 7800,
|
||||
'minExecutionTime' => 50,
|
||||
),
|
||||
'globalSearchEntityList' =>
|
||||
array (
|
||||
0 => 'Account',
|
||||
1 => 'Contact',
|
||||
2 => 'Lead',
|
||||
3 => 'Prospect',
|
||||
4 => 'Opportunity',
|
||||
),
|
||||
'tabList' =>
|
||||
array (
|
||||
0 => 'Contact',
|
||||
1 => 'Account',
|
||||
2 => 'Lead',
|
||||
3 => 'Opportunity',
|
||||
4 => 'Calendar',
|
||||
5 => 'Meeting',
|
||||
6 => 'Call',
|
||||
7 => 'Task',
|
||||
8 => 'Case',
|
||||
9 => 'Prospect',
|
||||
),
|
||||
'quickCreateList' =>
|
||||
array (
|
||||
0 => 'Account',
|
||||
1 => 'Contact',
|
||||
2 => 'Lead',
|
||||
3 => 'Opportunity',
|
||||
4 => 'Meeting',
|
||||
5 => 'Call',
|
||||
6 => 'Task',
|
||||
7 => 'Case',
|
||||
8 => 'Prospect',
|
||||
),
|
||||
'crud' =>
|
||||
array (
|
||||
'get' => 'read',
|
||||
'post' => 'create',
|
||||
'put' => 'update',
|
||||
'patch' => 'patch',
|
||||
'delete' => 'delete',
|
||||
),
|
||||
'systemUser' =>
|
||||
array (
|
||||
'id' => 'system',
|
||||
'userName' => 'system',
|
||||
'firstName' => '',
|
||||
'lastName' => 'System',
|
||||
),
|
||||
'systemItems' =>
|
||||
array (
|
||||
0 => 'systemItems',
|
||||
1 => 'adminItems',
|
||||
2 => 'configPath',
|
||||
3 => 'cachePath',
|
||||
4 => 'database',
|
||||
5 => 'crud',
|
||||
6 => 'logger',
|
||||
7 => 'isInstalled',
|
||||
8 => 'defaultPermissions',
|
||||
9 => 'systemUser',
|
||||
),
|
||||
'adminItems' =>
|
||||
array (
|
||||
0 => 'devMode',
|
||||
1 => 'outboundEmailIsShared',
|
||||
2 => 'outboundEmailFromName',
|
||||
3 => 'outboundEmailFromAddress',
|
||||
4 => 'smtpServer',
|
||||
5 => 'smtpPort',
|
||||
6 => 'smtpAuth',
|
||||
7 => 'smtpSecurity',
|
||||
8 => 'smtpUsername',
|
||||
9 => 'smtpPassword',
|
||||
10 => 'cron',
|
||||
),
|
||||
'isInstalled' => true,
|
||||
'cacheTimestamp' => 1399456816,
|
||||
'testOption' => 'Another Wrong Value',
|
||||
'testOption2' => 'Test2',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user