installer inmpovements

This commit is contained in:
Taras Machyshyn
2014-04-14 17:38:36 +03:00
parent df0a65b7c1
commit 120b568005
4 changed files with 40 additions and 6 deletions
+36 -1
View File
@@ -188,9 +188,20 @@ class Installer
public function setPreferences($preferences)
{
return $this->saveConfig($preferences);
$currencyList = $this->app->getContainer()->get('config')->get('currencyList');
if (!in_array($preferences['defaultCurrency'], $currencyList)) {
$preferences['currencyList'] = array($preferences['defaultCurrency']);
}
$res = $this->saveConfig($preferences);
/*save these settings for admin*/
$this->setAdminPreferences($preferences);
return $res;
}
protected function createRecords()
{
$records = include('install/core/init/records.php');
@@ -260,6 +271,30 @@ class Installer
return $result;
}
protected function setAdminPreferences($preferences)
{
$allowedPreferences = array(
'dateFormat',
'timeFormat',
'timeZone',
'weekStart',
'defaultCurrency',
'thousandSeparator',
'decimalMark',
'language',
);
$data = array_intersect_key($preferences, array_flip($allowedPreferences));
$entity = $this->getEntityManager()->getEntity('Preferences', '1');
if ($entity) {
$entity->set($data);
return $this->getEntityManager()->saveEntity($entity);
}
return false;
}
public function isWritable()
{
$this->writableListError = array();
+1 -1
View File
@@ -31,6 +31,6 @@ $cronTitle = (isset($langs['cronTitle'][$serverType]))? $langs['cronTitle'][$ser
$smarty->assign('cronTitle', $cronTitle);
$smarty->assign('cronHelp', $cronHelp);
// clean session
$installer->setSuccess();
// clean session
session_unset();
+3 -3
View File
@@ -23,7 +23,7 @@
ob_start();
$result = array('success' => false, 'errorMsg' => '');
if (!empty($_SESSION['install'])) {// required fields //['user-name']) && !empty($_SESSION['install']['user-pass'])) {
if (!empty($_SESSION['install'])) {
$preferences = array(
'dateFormat' => $_SESSION['install']['dateFormat'],
'timeFormat' => $_SESSION['install']['timeFormat'],
@@ -35,13 +35,13 @@ if (!empty($_SESSION['install'])) {// required fields //['user-name']) && !empty
'language' => $_SESSION['install']['language'],
'smtpServer' => $_SESSION['install']['smtpServer'],
'smtpPort' => $_SESSION['install']['smtpPort'],
'smtpAuth' => $_SESSION['install']['smtpAuth'],
'smtpAuth' => (empty($_SESSION['install']['smtpAuth']) || $_SESSION['install']['smtpAuth'] == 'false' || !$_SESSION['install']['smtpAuth'])? false : true,
'smtpSecurity' => $_SESSION['install']['smtpSecurity'],
'smtpUsername' => $_SESSION['install']['smtpUsername'],
'smtpPassword' => $_SESSION['install']['smtpPassword'],
'outboundEmailFromName' => $_SESSION['install']['outboundEmailFromName'],
'outboundEmailFromAddress' => $_SESSION['install']['outboundEmailFromAddress'],
'outboundEmailIsShared' => $_SESSION['install']['outboundEmailIsShared'],
'outboundEmailIsShared' => (empty($_SESSION['install']['smtpAuth']) || $_SESSION['install']['outboundEmailIsShared'] == 'false' || !$_SESSION['install']['smtpAuth'])? false : true,
);
$res = $installer->setPreferences($preferences);
if (!empty($res)) {
-1
View File
@@ -20,7 +20,6 @@
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
//error_reporting(-1);
session_start();
require_once('../bootstrap.php');