installer minor fixes
This commit is contained in:
@@ -148,7 +148,7 @@ class Installer
|
||||
*/
|
||||
public function saveData($database, $language)
|
||||
{
|
||||
$initData = include('install/core/init/config.php');
|
||||
$initData = include('install/core/afterInstall/config.php');
|
||||
|
||||
$siteUrl = $this->getSystemHelper()->getBaseUrl();
|
||||
|
||||
@@ -208,7 +208,7 @@ class Installer
|
||||
|
||||
protected function createRecords()
|
||||
{
|
||||
$records = include('install/core/init/records.php');
|
||||
$records = include('install/core/afterInstall/records.php');
|
||||
|
||||
$result = true;
|
||||
foreach ($records as $entityName => $recordList) {
|
||||
@@ -269,8 +269,6 @@ class Installer
|
||||
|
||||
$result = $this->createRecord('User', $user);
|
||||
|
||||
$result &= $this->createRecords();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -313,9 +311,16 @@ 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;
|
||||
}
|
||||
@@ -377,5 +382,21 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class SystemHelper extends \Espo\Core\Utils\System
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function checkDbConnection($hostName, $port ,$dbUserName, $dbUserPass, $dbName, $dbDriver = 'pdo_mysql')
|
||||
public function checkDbConnection($hostName, $port, $dbUserName, $dbUserPass, $dbName, $dbDriver = 'pdo_mysql', $isCreateDatabase = true)
|
||||
{
|
||||
$result['success'] = true;
|
||||
|
||||
@@ -104,6 +104,28 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://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/.
|
||||
************************************************************************/
|
||||
|
||||
return array(
|
||||
|
||||
);
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://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/.
|
||||
************************************************************************/
|
||||
|
||||
return array(
|
||||
'EmailTemplate' => array(
|
||||
0 => array(
|
||||
'name' => 'Case-to-Email auto-reply',
|
||||
'subject' => 'Case has been created',
|
||||
'body' => '<p>{Person.name},</p><p>Case \'{Case.name}\' has been created with number {Case.number} and assigned to {User.name}.</p>',
|
||||
'isHtml ' => '1',
|
||||
),
|
||||
),
|
||||
'ScheduledJob' => array(
|
||||
0 => array(
|
||||
'name' => 'Check Inbound Emails',
|
||||
'job' => 'CheckInboundEmails',
|
||||
'status' => 'Active',
|
||||
'scheduling' => '/10 * * * *',
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'EmailTemplate' => array(
|
||||
0 => array(
|
||||
'name' => 'Case-to-Email auto-reply',
|
||||
'subject' => 'Case has been created',
|
||||
'body' => '<p>Hi {Person.name}</p><p>Case \'<span style="line-height: 1.36;">{Case.name}\'</span><span style="line-height: 1.36;"> has been created with number \'{Case.number}\' and a</span><span style="line-height: 1.36;">ssigned to {User.name}.</span></p>',
|
||||
'isHtml ' => '1',
|
||||
),
|
||||
),
|
||||
'ScheduledJob' => array(
|
||||
0 => array(
|
||||
'name' => 'Check Inbound Emails',
|
||||
'job' => 'CheckInboundEmails',
|
||||
'status' => 'Active',
|
||||
'scheduling' => '/10 * * * *',
|
||||
),
|
||||
),
|
||||
);
|
||||
Reference in New Issue
Block a user