diff --git a/install/core/Installer.php b/install/core/Installer.php index 246b54b19d..2375893bbd 100644 --- a/install/core/Installer.php +++ b/install/core/Installer.php @@ -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(); diff --git a/install/core/actions/finish.php b/install/core/actions/finish.php index 90d89125e0..b3e1afefe3 100644 --- a/install/core/actions/finish.php +++ b/install/core/actions/finish.php @@ -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(); \ No newline at end of file diff --git a/install/core/actions/setPreferences.php b/install/core/actions/setPreferences.php index 231a17c79a..dd089e6937 100644 --- a/install/core/actions/setPreferences.php +++ b/install/core/actions/setPreferences.php @@ -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)) { diff --git a/install/index.php b/install/index.php index 7f25a57ebb..40c7bbe94e 100644 --- a/install/index.php +++ b/install/index.php @@ -20,7 +20,6 @@ * along with EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ -//error_reporting(-1); session_start(); require_once('../bootstrap.php');