From 1e866da2aa422e685544bfbab9cd1a61a0b61efe Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Tue, 15 Apr 2014 17:44:18 +0300 Subject: [PATCH] installer modification --- install/core/Installer.php | 5 +- install/core/SystemHelper.php | 20 +- install/core/actions/applySett.php | 2 +- install/core/actions/checkWritable.php | 2 +- install/core/actions/finish.php | 10 +- install/core/actions/setEmailSett.php | 53 +++ install/core/actions/setPreferences.php | 9 - install/core/actions/step2.php | 2 +- install/core/actions/step3.php | 2 +- install/core/actions/step4.php | 13 - install/core/actions/step5.php | 48 +++ install/core/i18n/en_US.php | 163 ---------- install/core/i18n/en_US/install.json | 118 +++++++ install/core/tpl/errors.tpl | 4 +- install/core/tpl/finish.tpl | 6 +- install/core/tpl/main.tpl | 8 +- install/core/tpl/step1.tpl | 8 +- install/core/tpl/step2.tpl | 16 +- install/core/tpl/step3.tpl | 12 +- install/core/tpl/step4.tpl | 413 ++++++++---------------- install/core/tpl/step5.tpl | 127 ++++++++ install/index.php | 17 +- install/js/install.js | 161 ++++++--- 23 files changed, 650 insertions(+), 569 deletions(-) create mode 100644 install/core/actions/setEmailSett.php create mode 100644 install/core/actions/step5.php delete mode 100644 install/core/i18n/en_US.php create mode 100644 install/core/i18n/en_US/install.json create mode 100644 install/core/tpl/step5.tpl diff --git a/install/core/Installer.php b/install/core/Installer.php index 2375893bbd..caff6fe16a 100644 --- a/install/core/Installer.php +++ b/install/core/Installer.php @@ -189,7 +189,7 @@ class Installer public function setPreferences($preferences) { $currencyList = $this->app->getContainer()->get('config')->get('currencyList'); - if (!in_array($preferences['defaultCurrency'], $currencyList)) { + if (isset($preferences['defaultCurrency']) && !in_array($preferences['defaultCurrency'], $currencyList)) { $preferences['currencyList'] = array($preferences['defaultCurrency']); } @@ -285,6 +285,9 @@ class Installer ); $data = array_intersect_key($preferences, array_flip($allowedPreferences)); + if (empty($data)) { + return true; + } $entity = $this->getEntityManager()->getEntity('Preferences', '1'); if ($entity) { diff --git a/install/core/SystemHelper.php b/install/core/SystemHelper.php index 1c42605e47..a2b48b27ef 100644 --- a/install/core/SystemHelper.php +++ b/install/core/SystemHelper.php @@ -35,29 +35,21 @@ class SystemHelper protected $modRewriteUrl = '/api/v1/Metadata'; - protected $systemConfig = 'data/config.php'; + protected $writableDir = 'data'; public function initWritable() { - $pathInfo = pathinfo($this->systemConfig); - - if (!is_writable($pathInfo['dirname'])) { - return false; + if (is_writable($this->writableDir)) { + return true; } - if (!@touch($this->systemConfig)) { - return false; - } - - return true; + return false; } - public function getSystemDir() + public function getWritableDir() { - $pathInfo = pathinfo($this->systemConfig); - - return $pathInfo['dirname']; + return $this->writableDir; } diff --git a/install/core/actions/applySett.php b/install/core/actions/applySett.php index 1f8eded2fe..cbddbe1b9e 100644 --- a/install/core/actions/applySett.php +++ b/install/core/actions/applySett.php @@ -34,7 +34,7 @@ $data = array( $lang = (!empty($_SESSION['install']['user-lang']))? $_SESSION['install']['user-lang'] : 'en_US'; if (!$installer->saveData($data, $lang)) { $result['success'] = false; - $result['errorMsg'] = $langs['Can not save settings']; + $result['errorMsg'] = $langs['messages']['Can not save settings']; } ob_clean(); diff --git a/install/core/actions/checkWritable.php b/install/core/actions/checkWritable.php index 327024824b..8b0623da80 100644 --- a/install/core/actions/checkWritable.php +++ b/install/core/actions/checkWritable.php @@ -29,7 +29,7 @@ if (!$installer->isWritable()) { foreach ($urls as &$url) { $url = '        '.$url; } - $result['errorMsg'] = $langs['Permission denied to files'].':
'.implode('
', $urls); + $result['errorMsg'] = $langs['messages']['Permission denied to files'].':
'.implode('
', $urls); $result['errorFixInstruction'] = $systemHelper->getPermissionCommands('', array('644', '755')); } diff --git a/install/core/actions/finish.php b/install/core/actions/finish.php index b3e1afefe3..d8af5ccaf9 100644 --- a/install/core/actions/finish.php +++ b/install/core/actions/finish.php @@ -20,14 +20,14 @@ * along with EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ -$serverType = $systemHelper->getServerType(); +$os = $systemHelper->getOS(); $cronFile = $systemHelper->getRootDir().DIRECTORY_SEPARATOR.'cron.php'; -$cronHelp = (isset($langs['cronHelp'][$serverType]))? $langs['cronHelp'][$serverType] : $langs['cronHelp']['default']; -$cronHelp = str_replace('', $cronFile, $cronHelp); -$cronHelp = str_replace('', $systemHelper->getPhpBin(), $cronHelp); -$cronTitle = (isset($langs['cronTitle'][$serverType]))? $langs['cronTitle'][$serverType] : $langs['cronTitle']['default']; +$cronHelp = (isset($langs['options']['cronHelp'][$os]))? $langs['options']['cronHelp'][$os] : $langs['options']['cronHelp']['default']; +$cronHelp = str_replace('{cronFile}', $cronFile, $cronHelp); +$cronHelp = str_replace('{phpBinDir}', $systemHelper->getPhpBin(), $cronHelp); +$cronTitle = (isset($langs['options']['cronTitle'][$os]))? $langs['options']['cronTitle'][$os] : $langs['options']['cronTitle']['default']; $smarty->assign('cronTitle', $cronTitle); $smarty->assign('cronHelp', $cronHelp); diff --git a/install/core/actions/setEmailSett.php b/install/core/actions/setEmailSett.php new file mode 100644 index 0000000000..842114002d --- /dev/null +++ b/install/core/actions/setEmailSett.php @@ -0,0 +1,53 @@ + false, 'errorMsg' => ''); + +if (!empty($_SESSION['install'])) { + $preferences = array( + 'smtpServer' => $_SESSION['install']['smtpServer'], + 'smtpPort' => $_SESSION['install']['smtpPort'], + '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' => (empty($_SESSION['install']['smtpAuth']) || $_SESSION['install']['outboundEmailIsShared'] == 'false' || !$_SESSION['install']['smtpAuth'])? false : true, + ); + $res = $installer->setPreferences($preferences); + if (!empty($res)) { + $result['success'] = true; + } + else { + $result['success'] = false; + $result['errorMsg'] = 'Cannot save preferences'; + } +} +else { + $result['success'] = false; + $result['errorMsg'] = 'Cannot save preferences'; +} + +ob_clean(); +echo json_encode($result); diff --git a/install/core/actions/setPreferences.php b/install/core/actions/setPreferences.php index dd089e6937..7427e297f4 100644 --- a/install/core/actions/setPreferences.php +++ b/install/core/actions/setPreferences.php @@ -33,15 +33,6 @@ if (!empty($_SESSION['install'])) { 'thousandSeparator' => $_SESSION['install']['thousandSeparator'], 'decimalMark' => $_SESSION['install']['decimalMark'], 'language' => $_SESSION['install']['language'], - 'smtpServer' => $_SESSION['install']['smtpServer'], - 'smtpPort' => $_SESSION['install']['smtpPort'], - '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' => (empty($_SESSION['install']['smtpAuth']) || $_SESSION['install']['outboundEmailIsShared'] == 'false' || !$_SESSION['install']['smtpAuth'])? false : true, ); $res = $installer->setPreferences($preferences); if (!empty($res)) { diff --git a/install/core/actions/step2.php b/install/core/actions/step2.php index a944964f5b..a18100219a 100644 --- a/install/core/actions/step2.php +++ b/install/core/actions/step2.php @@ -23,7 +23,7 @@ $fields = array( 'db-name' => array(), 'host-name' => array( - 'default' => (isset($langs['localhost']))? $langs['localhost'] : '',), + 'default' => (isset($langs['labels']['localhost']))? $langs['labels']['localhost'] : '',), 'db-user-name' => array(), 'db-user-password' => array(), 'db-driver' => array() diff --git a/install/core/actions/step3.php b/install/core/actions/step3.php index c08694475a..7099ce41a7 100644 --- a/install/core/actions/step3.php +++ b/install/core/actions/step3.php @@ -22,7 +22,7 @@ $fields = array( 'user-name' => array( - 'default' => (isset($langs['admin']))? $langs['admin'] : 'admin', + 'default' => (isset($langs['labels']['admin']))? $langs['labels']['admin'] : 'admin', ), 'user-pass' => array(), 'user-confirm-pass' => array(), diff --git a/install/core/actions/step4.php b/install/core/actions/step4.php index fe4626cf72..d810d903e9 100644 --- a/install/core/actions/step4.php +++ b/install/core/actions/step4.php @@ -38,20 +38,7 @@ $fields = array( ), 'language' => array( 'default'=> (!empty($_SESSION['install']['user-lang'])) ? $_SESSION['install']['user-lang'] : 'en_US' - ), - 'smtpServer' => array(), - 'smtpPort' => array( - 'default' => '25', ), - 'smtpAuth' => array(), - 'smtpSecurity' => array( - 'default' => (isset($settingsDefaults['smtpSecurity']['default'])) ? $settingsDefaults['smtpSecurity']['default'] : ''), - 'smtpUsername' => array(), - 'smtpPassword' => array(), - - 'outboundEmailFromName' => array(), - 'outboundEmailFromAddress' => array(), - 'outboundEmailIsShared' => array(), ); foreach ($fields as $fieldName => $field) { diff --git a/install/core/actions/step5.php b/install/core/actions/step5.php new file mode 100644 index 0000000000..702a5c7563 --- /dev/null +++ b/install/core/actions/step5.php @@ -0,0 +1,48 @@ + array(), + 'smtpPort' => array( + 'default' => '25', + ), + 'smtpAuth' => array(), + 'smtpSecurity' => array( + 'default' => (isset($settingsDefaults['smtpSecurity']['default'])) ? $settingsDefaults['smtpSecurity']['default'] : ''), + 'smtpUsername' => array(), + 'smtpPassword' => array(), + + 'outboundEmailFromName' => array(), + 'outboundEmailFromAddress' => array(), + 'outboundEmailIsShared' => array(), +); + +foreach ($fields as $fieldName => $field) { + if (isset($_SESSION['install'][$fieldName])) { + $fields[$fieldName]['value'] = $_SESSION['install'][$fieldName]; + } + else { + $fields[$fieldName]['value'] = (isset($fields[$fieldName]['default']))? $fields[$fieldName]['default'] : ''; + } +} + +$smarty->assign('fields', $fields); diff --git a/install/core/i18n/en_US.php b/install/core/i18n/en_US.php deleted file mode 100644 index 6ab2c67ff5..0000000000 --- a/install/core/i18n/en_US.php +++ /dev/null @@ -1,163 +0,0 @@ - 'Welcome to EspoCRM', - 'Main page header' => '', - 'Bad init Permission' => 'Permission denied for "{*}" directory. Please set 775 for "{*}" or just execute this command in the terminal
{C}
- Operation not permitted? Try this one: {CSU}', - 'Start page title' => 'License Agreement', - 'Step1 page title' => 'License Agreement', - 'License Agreement' => 'License Agreement', - 'I accept the agreement' => 'I accept the agreement', - 'Choose your language:' => 'Choose your language:', - 'Database Name' => 'Database Name', - 'Host Name' => 'Host Name', - 'Database User Name' => 'Database User Name', - 'Database User Password' => 'Database User Password', - 'Database driver' => 'Database driver', - 'Step2 page title' => 'Database configuration', - 'Step3 page title' => 'Administrator Setup', - 'Step4 page title' => 'System Settings', - 'User Name' => 'User Name', - 'Password' => 'Password', - 'Confirm Password' => 'Confirm your Password', - 'Errors page title' => 'Errors', - 'Finish page title' => 'Installation is complete', - 'Congratulation! Welcome to EspoCRM!' => 'Congratulation! EspoCRM has been successfully installed.', - 'admin' => 'admin', - 'localhost' => 'localhost', - - 'Locale' => 'Locale', - 'Outbound Email Configuration' => 'Outbound Email Configuration', - 'SMTP' => 'SMTP', - 'From Address' => 'From Address', - 'From Name' => 'From Name', - 'Is Shared' => 'Is Shared', - 'Date Format' => 'Date Format', - 'Time Format' => 'Time Format', - 'Time Zone' => 'Time Zone', - 'First Day of Week' => 'First Day of Week', - 'Thousand Separator' => 'Thousand Separator', - 'Decimal Mark' => 'Decimal Mark', - 'Default Currency' => 'Default Currency', - 'Currency List' => 'Currency List', - 'Language' => 'Language', - - 'smtpServer' => 'Server', - 'smtpPort' => 'Port', - 'smtpAuth' => 'Auth', - 'smtpSecurity' => 'Security', - 'smtpUsername' => 'Username', - 'emailAddress' => 'Email', - 'smtpPassword' => 'Password', - - - // messages - 'Some errors occurred!' => 'Some errors occurred!', - 'Supported php version >=' => 'Supported php version >=', - 'The PHP extension was not found...' => 'The PHP extension was not found...', - 'All Settings correct' => 'All Settings are correct', - 'Failed to connect to database' => 'Failed to connect to database', - 'PHP version:' => 'PHP version:', - 'You must agree to the license agreement' => 'You must agree to the license agreement', - 'Passwords do not match' => 'Passwords do not match', - 'Enable mod_rewrite in Apache server' => 'Enable mod_rewrite in Apache server', - 'checkWritable error' => 'checkWritable error', - 'applySett error' => 'applySett error', - 'buildDatabse error' => 'buildDatabse error', - 'createUser error' => 'createUser error', - 'checkAjaxPermission error' => 'checkAjaxPermission error', - 'Ajax failed' => 'Ajax failed', - 'Cannot create user' => 'Cannot create user', - 'Permission denied' => 'Permission denied', - 'permissionInstruction' => '
Run this in Terminal
"{C}"
', - 'Permission denied to files' => 'Permission denied to file(s)', - 'Can not save settings' => 'Can not save settings', - 'Cannot save preferences' => 'Cannot save preferences', - - 'db driver' => array( - 'mysqli' => 'MySQLi', - 'pdo_mysql' => 'PDO MySQL', - ), - - 'modRewriteInstruction' => array( - 'apache' => array( - 'linux' => '

Run those commands in Terminal
1. a2enmod rewrite 
2. service apache2 restart
', - 'windows' => '
1. Find the httpd.conf file (usually you will find it in a folder called conf, config or something along those lines)
-2. Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound \'#\' sign from in front of the line)
-3. Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out. -
', - ), - 'microsoft-iis' => array( - 'windows' => '', - - ), - ), - - 'modRewriteHelp' => array( - 'apache' => 'Enable "mod_rewrite" in Apache server', - 'nginx' => 'Add this code to Nginx Host Config (inside "server" block):
-
-location /api/v1/ {
-    if (!-e $request_filename){
-        rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;
-    }
-}
-
-location / {
-    rewrite reset/?$ reset.html break;
-}
', - 'microsoft-iis' => 'Enable "URL Rewrite" Module in IIS server', - 'default' => 'Enable Rewrite Module in your server (e.g. mod_rewrite in Apache)', - ), - - 'cronTitle' => array( - 'apache' => 'To Setup Crontab:', - 'nginx' => 'To Setup Crontab:', - 'microsoft-iis' => 'To Setup Scheduled Task:', - 'default' => 'To Setup Cron job:', - ), - - 'cronHelp' => array( - 'apache' => 'Note: Add this line to the crontab file to run Espo Scheduled Jobs: -* * * * * -f > /dev/null 2>&1', - 'nginx' => 'Note: Add this line to Tasks to run Espo Scheduled Jobs: -* * * * * -f > /dev/null 2>&1', - 'microsoft-iis' => 'Note: Create a batch file with the following commands to run Espo Scheduled Jobs using Windows Scheduled Tasks: -.exe -f ', - 'default' => 'Run command ', - ), - - // controll - 'Start' => 'Start', - 'Back' => 'Back', - 'Next' => 'Next', - 'Go to EspoCRM' => 'Go to EspoCRM', - 'Re-check' => 'Re-check', - 'Test settings' => 'Test Connection', - - // db errors - '1049' => 'Unknown database', - '2005' => 'Unknown MySQL server host', - '1045' => 'Access denied for user', -); diff --git a/install/core/i18n/en_US/install.json b/install/core/i18n/en_US/install.json new file mode 100644 index 0000000000..7ed2a7011d --- /dev/null +++ b/install/core/i18n/en_US/install.json @@ -0,0 +1,118 @@ +{ + "labels": { + "Main page title": "Welcome to EspoCRM", + "Main page header": "", + "Start page title": "License Agreement", + "Step1 page title": "License Agreement", + "License Agreement": "License Agreement", + "I accept the agreement": "I accept the agreement", + "Step2 page title": "Database configuration", + "Step3 page title": "Administrator Setup", + "Step4 page title": "System settings", + "Step5 page title": "SMTP settings for outgoing emails", + "Errors page title": "Errors", + "Finish page title": "Installation is complete", + "Congratulation! Welcome to EspoCRM!": "Congratulation! EspoCRM has been successfully installed.", + "admin": "admin", + "localhost": "localhost", + "Locale": "Locale", + "Outbound Email Configuration": "Outbound Email Configuration", + "SMTP": "SMTP", + "Start": "Start", + "Back": "Back", + "Next": "Next", + "Go to EspoCRM": "Go to EspoCRM", + "Re-check": "Re-check", + "Test settings": "Test Connection" + }, + "fields": { + "Choose your language:": "Choose your language:", + "Database Name": "Database Name", + "Host Name": "Host Name", + "Database User Name": "Database User Name", + "Database User Password": "Database User Password", + "Database driver": "Database driver", + "User Name": "User Name", + "Password": "Password", + "Confirm Password": "Confirm your Password", + "From Address": "From Address", + "From Name": "From Name", + "Is Shared": "Is Shared", + "Date Format": "Date Format", + "Time Format": "Time Format", + "Time Zone": "Time Zone", + "First Day of Week": "First Day of Week", + "Thousand Separator": "Thousand Separator", + "Decimal Mark": "Decimal Mark", + "Default Currency": "Default Currency", + "Currency List": "Currency List", + "Language": "Language", + "smtpServer": "Server", + "smtpPort": "Port", + "smtpAuth": "Auth", + "smtpSecurity": "Security", + "smtpUsername": "Username", + "emailAddress": "Email", + "smtpPassword": "Password" + }, + "messages": { + "Bad init Permission": "Permission denied for \"{*}\" directory. Please set 775 for \"{*}\" or just execute this command in the terminal
{C}<\/b><\/pre>\n\tOperation not permitted? Try this one: {CSU}",
+		"Some errors occurred!": "Some errors occurred!",
+		"Supported php version >=": "Supported php version >=",
+		"The PHP extension was not found...": "The {extName}<\/b> PHP extension was not found...",
+		"All Settings correct": "All Settings are correct",
+		"Failed to connect to database": "Failed to connect to database",
+		"PHP version:": "PHP version:",
+		"You must agree to the license agreement": "You must agree to the license agreement",
+		"Passwords do not match": "Passwords do not match",
+		"Enable mod_rewrite in Apache server": "Enable mod_rewrite in Apache server",
+		"checkWritable error": "checkWritable error",
+		"applySett error": "applySett error",
+		"buildDatabse error": "buildDatabse error",
+		"createUser error": "createUser error",
+		"checkAjaxPermission error": "checkAjaxPermission error",
+		"Ajax failed": "Ajax failed",
+		"Cannot create user": "Cannot create user",
+		"Permission denied": "Permission denied",
+		"permissionInstruction": "
Run this in Terminal
\"{C}\"<\/b><\/pre>",
+		"Permission denied to files": "Permission denied to file(s)",
+		"Can not save settings": "Can not save settings",
+		"Cannot save preferences": "Cannot save preferences",
+		"Thousand Separator and Decimal Mark equal": "Thousand Separator and Decimal Mark cannot be equal",
+		"1049": "Unknown database",
+		"2005": "Unknown MySQL server host",
+		"1045": "Access denied for user"
+	},
+	"options": {
+		"db driver": {
+			"mysqli": "MySQLi",
+			"pdo_mysql": "PDO MySQL"
+		},
+		"modRewriteInstruction": {
+			"apache": {
+				"linux": "

Run those commands in Terminal
1. a2enmod rewrite 
2. service apache2 restart<\/b><\/pre>", + "windows": "
1. Find the httpd.conf file (usually you will find it in a folder called conf, config or something along those lines)
\n2. Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules\/mod_rewrite.so (remove the pound '#' sign from in front of the line)
\n3. Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out.\n<\/pre>" + }, + "microsoft-iis": { + "windows": "" + } + }, + "modRewriteHelp": { + "apache": "Enable \"mod_rewrite\" in Apache server", + "nginx": "Add this code to Nginx Host Config (inside \"server\" block):
\n
\nlocation \/api\/v1\/ {\n    if (!-e $request_filename){\n        rewrite ^\/api\/v1\/(.*)$ \/api\/v1\/index.php last; break;\n    }\n}\n\nlocation \/ {\n    rewrite reset\/?$ reset.html break;\n}<\/pre>",
+			"microsoft-iis": "Enable \"URL Rewrite\" Module in IIS server",
+			"default": "Enable Rewrite Module in your server (e.g. mod_rewrite in Apache)"
+		},
+		"cronTitle": {
+			"linux": "To Setup Crontab:",
+			"windows": "To Setup Scheduled Task:",
+			"default": "To Setup Cron job:"
+		},
+		"cronHelp": {
+			"linux": "Note: Add this line to the crontab file to run Espo Scheduled Jobs:\n* * * * * {phpBinDir} -f {cronFile} > \/dev\/null 2>&1",
+			"mac": "Note: Add this line to Tasks to run Espo Scheduled Jobs:\n* * * * * {phpBinDir} -f {cronFile} > \/dev\/null 2>&1",
+			"windows": "Note: Create a batch file with the following commands to run Espo Scheduled Jobs using Windows Scheduled Tasks:\n{phpBinDir}.exe -f {cronFile}",
+			"default": "Run command {cronFile}"
+		}
+	}
+}
\ No newline at end of file
diff --git a/install/core/tpl/errors.tpl b/install/core/tpl/errors.tpl
index b18080e7a6..c847b623eb 100644
--- a/install/core/tpl/errors.tpl
+++ b/install/core/tpl/errors.tpl
@@ -1,5 +1,5 @@
 
-

{$langs['Errors page title']}

+

{$langs['labels']['Errors page title']}

{$errors}
@@ -14,7 +14,7 @@
- +
diff --git a/install/core/tpl/step5.tpl b/install/core/tpl/step5.tpl new file mode 100644 index 0000000000..8e6dd652ba --- /dev/null +++ b/install/core/tpl/step5.tpl @@ -0,0 +1,127 @@ +
+

{$langs['labels']['Step5 page title']}

+
+
+
+
+ +
+
+ + +
+ diff --git a/install/index.php b/install/index.php index 40c7bbe94e..abf8a8bab6 100644 --- a/install/index.php +++ b/install/index.php @@ -26,21 +26,22 @@ require_once('../bootstrap.php'); // get user selected language $userLang = (!empty($_SESSION['install']['user-lang']))? $_SESSION['install']['user-lang'] : 'en_US'; -$langFileName = 'core/i18n/'.$userLang.'.php'; +$langFileName = 'core/i18n/'.$userLang.'/install.json'; $langs = array(); if (file_exists('install/'.$langFileName)) { - $langs = include($langFileName); + $langs = file_get_contents('install/'.$langFileName); } else { - $langs = include('core/i18n/en_US.php'); + $langs = file_get_contents('install/core/i18n/en_US/install.json'); } +$langs = json_decode($langs, true); require_once 'core/SystemHelper.php'; $systemHelper = new SystemHelper(); if (!$systemHelper->initWritable()) { - $dir = $systemHelper->getSystemDir(); + $dir = $systemHelper->getWritableDir(); - $message = $langs['Bad init Permission']; + $message = $langs['messages']['Bad init Permission']; $message = str_replace('{*}', $dir, $message); $message = str_replace('{C}', $systemHelper->getPermissionCommands(array($dir, ''), '775'), $message); $message = str_replace('{CSU}', $systemHelper->getPermissionCommands(array($dir, ''), '775', true), $message); @@ -108,7 +109,11 @@ switch ($action) { break; case 'step4': - case 'errors': + $settingsDefaults = $installer->getSettingDefaults(); + $smarty->assign("settingsDefaults", $settingsDefaults); + break; + + case 'step5': $settingsDefaults = $installer->getSettingDefaults(); $smarty->assign("settingsDefaults", $settingsDefaults); break; diff --git a/install/js/install.js b/install/js/install.js index da46e1b7fe..1555462e34 100644 --- a/install/js/install.js +++ b/install/js/install.js @@ -49,7 +49,8 @@ var InstallScript = function(opt) { this.connSett = {}; this.userSett = {}; - this.firstUserPreferences = {}; + this.systemSettings = {}; + this.emailSettings = {}; this.checkActions = [ { 'action': 'checkModRewrite', @@ -110,7 +111,7 @@ InstallScript.prototype.step1 = function() { if (licenseAgree.length > 0 && !licenseAgree.is(':checked')) { $(this).removeAttr('disabled'); - self.showMsg({msg: self.getLang('You must agree to the license agreement'), error: true}); + self.showMsg({msg: self.getLang('You must agree to the license agreement', 'messages'), error: true}); } else { self.goTo(nextAction); @@ -142,7 +143,7 @@ InstallScript.prototype.step2 = function() { success: function(data) { if (data.success) { if (btn.attr('id') == 'next') self.goTo(nextAction); - else self.showMsg({msg: self.getLang('All Settings correct')}); + else self.showMsg({msg: self.getLang('All Settings correct', 'messages')}); } else { $('#next').removeAttr('disabled'); @@ -154,7 +155,7 @@ InstallScript.prototype.step2 = function() { $('#next').removeAttr('disabled'); $('#test-connection').removeAttr('disabled'); self.hideLoading(); - }, // success END + }, // error END }) // checkSett END @@ -183,11 +184,10 @@ InstallScript.prototype.step3 = function() { success: function(){ self.showLoading(); self.actionsChecking(); - //self.goTo(nextAction); }, error: function(msg) { $("#next").removeAttr('disabled'); - self.showMsg({msg: self.getLang(msg), error: true}); + self.showMsg({msg: self.getLang(msg, 'messages'), error: true}); } }); }) @@ -196,7 +196,7 @@ InstallScript.prototype.step3 = function() { InstallScript.prototype.step4 = function() { var self = this; var backAction = 'step3'; - var nextAction = 'finish'; + var nextAction = 'step5'; $('#back').click(function(){ $(this).attr('disabled', 'disabled'); @@ -205,12 +205,12 @@ InstallScript.prototype.step4 = function() { $("#next").click(function(){ $(this).attr('disabled', 'disabled'); - self.setFirstUserPreferences(); + self.setSystemSett(); if (!self.validate()) { $(this).removeAttr('disabled'); return; } - var data = self.firstUserPreferences; + var data = self.systemSettings; data.action = 'setPreferences'; $.ajax({ @@ -231,6 +231,65 @@ InstallScript.prototype.step4 = function() { }) } +InstallScript.prototype.step5 = function() { + var self = this; + var backAction = 'step4'; + var nextAction = 'finish'; + + $('#back').click(function(){ + $(this).attr('disabled', 'disabled'); + self.goTo(backAction); + }) + + $("#next").click(function(){ + $(this).attr('disabled', 'disabled'); + self.setEmailSett(); + if (!self.validate()) { + $(this).removeAttr('disabled'); + return; + } + var data = self.emailSettings; + + data.action = 'setEmailSett'; + $.ajax({ + url: "index.php", + type: "POST", + data: data, + dataType: 'json', + }) + .done(function(ajaxData){ + if (typeof(ajaxData) != 'undefined' && ajaxData.success) { + self.goTo(nextAction); + } + }) + .fail(function(ajaxData){ + + }) + + }) + + $('.field-smtpAuth').find('input[type="checkbox"]').change( function(e){ + if ($(this).is(':checked')) { + $('.cell-smtpPassword').removeClass('hide'); + $('.cell-smtpUsername').removeClass('hide'); + } + else { + $('.cell-smtpPassword').addClass('hide'); + $('.cell-smtpUsername').addClass('hide'); + $('.cell-smtpUsername').find('input').val(''); + $('.cell-smtpPassword').find('input').val(''); + } + }); + $('[name="smtpSecurity"]').change( function(e){ + if ($(this).val() == '') { + $('[name="smtpPort"]').val('25'); + } + else { + $('[name="smtpPort"]').val('465'); + } + }); +} + InstallScript.prototype.errors = function() { var self = this; @@ -266,25 +325,27 @@ InstallScript.prototype.setUserSett = function() { this.userSett.confPass = $('[name="user-confirm-pass"]').val(); } -InstallScript.prototype.setFirstUserPreferences = function() { - this.firstUserPreferences.dateFormat = $('[name="dateFormat"]').val(); - this.firstUserPreferences.timeFormat = $('[name="timeFormat"]').val(); - this.firstUserPreferences.timeZone = $('[name="timeZone"]').val(); - this.firstUserPreferences.weekStart = $('[name="weekStart"]').val(); - this.firstUserPreferences.defaultCurrency = $('[name="defaultCurrency"]').val(); - this.firstUserPreferences.thousandSeparator = $('[name="thousandSeparator"]').val(); - this.firstUserPreferences.decimalMark = $('[name="decimalMark"]').val(); - this.firstUserPreferences.language = $('[name="language"]').val(); - this.firstUserPreferences.smtpServer = $('[name="smtpServer"]').val(); - this.firstUserPreferences.smtpPort = $('[name="smtpPort"]').val(); - this.firstUserPreferences.smtpAuth = $('[name="smtpAuth"]').is(':checked'); - this.firstUserPreferences.smtpSecurity = $('[name="smtpSecurity"]').val(); - this.firstUserPreferences.smtpUsername = $('[name="smtpUsername"]').val(); - this.firstUserPreferences.smtpPassword = $('[name="smtpPassword"]').val(); - this.firstUserPreferences.outboundEmailFromName = $('[name="outboundEmailFromName"]').val(); - this.firstUserPreferences.outboundEmailFromAddress = $('[name="outboundEmailFromAddress"]').val(); - this.firstUserPreferences.outboundEmailIsShared = $('[name="outboundEmailIsShared"]').is(':checked'); +InstallScript.prototype.setSystemSett = function() { + this.systemSettings.dateFormat = $('[name="dateFormat"]').val(); + this.systemSettings.timeFormat = $('[name="timeFormat"]').val(); + this.systemSettings.timeZone = $('[name="timeZone"]').val(); + this.systemSettings.weekStart = $('[name="weekStart"]').val(); + this.systemSettings.defaultCurrency = $('[name="defaultCurrency"]').val(); + this.systemSettings.thousandSeparator = $('[name="thousandSeparator"]').val(); + this.systemSettings.decimalMark = $('[name="decimalMark"]').val(); + this.systemSettings.language = $('[name="language"]').val(); +} +InstallScript.prototype.setEmailSett = function() { + this.emailSettings.smtpServer = $('[name="smtpServer"]').val(); + this.emailSettings.smtpPort = $('[name="smtpPort"]').val(); + this.emailSettings.smtpAuth = $('[name="smtpAuth"]').is(':checked'); + this.emailSettings.smtpSecurity = $('[name="smtpSecurity"]').val(); + this.emailSettings.smtpUsername = $('[name="smtpUsername"]').val(); + this.emailSettings.smtpPassword = $('[name="smtpPassword"]').val(); + this.emailSettings.outboundEmailFromName = $('[name="outboundEmailFromName"]').val(); + this.emailSettings.outboundEmailFromAddress = $('[name="outboundEmailFromAddress"]').val(); + this.emailSettings.outboundEmailIsShared = $('[name="outboundEmailIsShared"]').is(':checked'); } InstallScript.prototype.checkSett = function(opt) { @@ -309,15 +370,15 @@ InstallScript.prototype.checkSett = function(opt) { if (typeof(data.errors)) { var errors = data.errors; if (typeof(errors.phpVersion) !== 'undefined') { - msg += self.getLang('Supported php version >=')+' '+errors.phpVersion+rowDelim; + msg += self.getLang('Supported php version >=', 'messages')+' '+errors.phpVersion+rowDelim; } if (typeof(errors.exts) !== 'undefined') { var exts = errors.exts; var len = exts.length; for (var index = 0; index < len; index++) { - var temp = self.getLang('The PHP extension was not found...'); - temp = temp.replace('', exts[index]); + var temp = self.getLang('The {extName} PHP extension was not found...', 'messages'); + temp = temp.replace('{extName}', exts[index]); msg += temp+rowDelim; } } @@ -328,7 +389,7 @@ InstallScript.prototype.checkSett = function(opt) { if (typeof(errors.dbConnect) !== 'undefined') { if (typeof(errors.dbConnect.errorCode) !== 'undefined') { - var temp = self.getLang(errors.dbConnect.errorCode); + var temp = self.getLang(errors.dbConnect.errorCode, 'messages'); if (temp == errors.dbConnect.errorCode && typeof(errors.dbConnect.errorMsg) !== 'undefined') temp = errors.dbConnect.errorMsg; } else if (typeof(errors.dbConnect.errorMsg) !== 'undefined') { @@ -339,7 +400,7 @@ InstallScript.prototype.checkSett = function(opt) { } if (msg == '') { - msg = self.getLang('Some errors occurred!'); + msg = self.getLang('Some errors occurred!', 'messages'); } self.showMsg({msg: msg, error: true}); } @@ -347,13 +408,15 @@ InstallScript.prototype.checkSett = function(opt) { opt.success(data); }) .fail(function(){ - msg = self.getLang('Ajax failed'); + msg = self.getLang('Ajax failed', 'messages'); self.showMsg({msg: msg, error: true}); opt.error(); }) } InstallScript.prototype.validate = function() { + this.hideMsg(); + var valid = true; var elem = null; var fieldRequired = []; @@ -365,7 +428,11 @@ InstallScript.prototype.validate = function() { fieldRequired = ['user-name', 'user-pass', 'user-confirm-pass']; break; case 'step4': - fieldRequired = ['thousandSeparator', 'decimalMark', 'smtpUsername']; + fieldRequired = ['decimalMark']; + break; + break; + case 'step5': + fieldRequired = ['smtpUsername']; break; @@ -383,6 +450,20 @@ InstallScript.prototype.validate = function() { } } } + + // decimal and group sep + $('[name="thousandSeparator"]').parent().parent().removeClass('has-error'); + if (typeof(this.systemSettings.thousandSeparator) !== 'undefined' + && typeof(this.systemSettings.decimalMark) !== 'undefined' + && this.systemSettings.thousandSeparator == this.systemSettings.decimalMark + && valid) { + + $('[name="thousandSeparator"]').parent().parent().addClass('has-error'); + $('[name="decimalMark"]').parent().parent().addClass('has-error'); + msg = this.getLang('Thousand Separator and Decimal Mark equal', 'messages'); + this.showMsg({msg: msg, error: true}); + valid = false; + } return valid; } @@ -408,8 +489,8 @@ InstallScript.prototype.goTo = function(action) { $('#nav').submit(); } -InstallScript.prototype.getLang = function(key) { - return (typeof(this.langs) !== 'undefined' && typeof(this.langs[key]) !== 'undefined')? this.langs[key] : key; +InstallScript.prototype.getLang = function(key, type) { + return (typeof(this.langs) !== 'undefined' && typeof(this.langs[type]) !== 'undefined' && typeof(this.langs[type][key]) !== 'undefined')? this.langs[type][key] : key; } InstallScript.prototype.showMsg = function(opt) { @@ -616,9 +697,9 @@ InstallScript.prototype.callbackAjaxPerm = function(data) { 'success': this.ajaxUrlPermRes } if (!this.ajaxUrlPermRes) { - var errorMsg = this.getLang('Permission denied') + ' ( ' + this.ajaxUrlPermMsgs.join(', ') + ' ) .'; + var errorMsg = this.getLang('Permission denied', 'messages') + ' ( ' + this.ajaxUrlPermMsgs.join(', ') + ' ) .'; if (this.ajaxUrlPermInstructions.length > 0) { - errorMsg += '
' + this.getLang('permissionInstruction').replace('"{C}"', this.ajaxUrlPermInstructions.join('
')); + errorMsg += '
' + this.getLang('permissionInstruction', 'messages').replace('"{C}"', this.ajaxUrlPermInstructions.join('
')); } ajaxData.errorMsg = errorMsg; } @@ -637,8 +718,8 @@ InstallScript.prototype.callbackModRewrite = function(data) { } ajaxData.success = false; if (typeof(this.langs) !== 'undefined') { - ajaxData.errorMsg = (typeof(this.langs['modRewriteHelp'][this.serverType]) !== 'undefined')? this.langs['modRewriteHelp'][this.serverType] : this.langs['modRewriteHelp']['default']; - ajaxData.errorMsg += (typeof(this.langs['modRewriteInstruction'][this.serverType]) !== 'undefined' && typeof(this.langs['modRewriteInstruction'][this.serverType][this.OS]) !== 'undefined') ? this.langs['modRewriteInstruction'][this.serverType][this.OS] : ''; + ajaxData.errorMsg = (typeof(this.langs['options']['modRewriteHelp'][this.serverType]) !== 'undefined')? this.langs['options']['modRewriteHelp'][this.serverType] : this.langs['options']['modRewriteHelp']['default']; + ajaxData.errorMsg += (typeof(this.langs['options']['modRewriteInstruction'][this.serverType]) !== 'undefined' && typeof(this.langs['options']['modRewriteInstruction'][this.serverType][this.OS]) !== 'undefined') ? this.langs['options']['modRewriteInstruction'][this.serverType][this.OS] : ''; } var realCheckIndex = this.checkIndex - 1; if (typeof(this.checkActions[realCheckIndex]) != 'undefined'