From e954275c06d790c2d0c163a59bff1aa30a8bd17b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 20 Jul 2015 15:13:23 +0200 Subject: First structure to skip steps during installation See https://github.com/FreshRSS/FreshRSS/issues/909 --- app/install.php | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index 745629aa7..6238f8a20 100644 --- a/app/install.php +++ b/app/install.php @@ -79,6 +79,31 @@ function saveLanguage() { } } +function saveStep1() { + if (isset($_POST['freshrss-keep-reinstall']) && + $_POST['freshrss-keep-reinstall'] === '1') { + // We want to keep our previous installation of FreshRSS + // so we need to make next steps valid by setting $_SESSION vars + // with values from the previous installation + + // TODO: set $_SESSION vars + $_SESSION['title'] = ''; + $_SESSION['old_entries'] = ''; + $_SESSION['mail_login'] = ''; + $_SESSION['default_user'] = ''; + + $_SESSION['bd_type'] = ''; + $_SESSION['bd_host'] = ''; + $_SESSION['bd_user'] = ''; + $_SESSION['bd_password'] = ''; + $_SESSION['bd_base'] = ''; + $_SESSION['bd_prefix'] = ''; + $_SESSION['bd_error'] = ''; + + header('Location: index.php?step=4'); + } +} + function saveStep2() { $user_default_config = Minz_Configuration::get('user'); if (!empty($_POST)) { @@ -302,6 +327,10 @@ function checkStep1() { ); } +function freshrss_already_installed() { + return false; +} + function checkStep2() { $conf = !empty($_SESSION['title']) && !empty($_SESSION['old_entries']) && @@ -537,7 +566,15 @@ function printStep1() {

- + +

+ +
+ + + +
+

@@ -788,6 +825,7 @@ default: saveLanguage(); break; case 1: + saveStep1(); break; case 2: saveStep2(); -- cgit v1.2.3 From 3dd2d56867db8aea8049c4b398e6ca2e1814cf67 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 20 Jul 2015 15:40:18 +0200 Subject: Load previous configuration during saveStep1() See https://github.com/FreshRSS/FreshRSS/issues/909 --- app/install.php | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index 6238f8a20..75a211064 100644 --- a/app/install.php +++ b/app/install.php @@ -9,8 +9,8 @@ session_name('FreshRSS'); session_set_cookie_params(0, dirname(empty($_SERVER['REQUEST_URI']) ? '/' : dirname($_SERVER['REQUEST_URI'])), null, false, true); session_start(); -Minz_Configuration::register('system', DATA_PATH . '/config.default.php'); -Minz_Configuration::register('user', USERS_PATH . '/_/config.default.php'); +Minz_Configuration::register('default_system', DATA_PATH . '/config.default.php'); +Minz_Configuration::register('default_user', USERS_PATH . '/_/config.default.php'); if (isset($_GET['step'])) { define('STEP',(int)$_GET['step']); @@ -86,18 +86,31 @@ function saveStep1() { // so we need to make next steps valid by setting $_SESSION vars // with values from the previous installation - // TODO: set $_SESSION vars - $_SESSION['title'] = ''; - $_SESSION['old_entries'] = ''; - $_SESSION['mail_login'] = ''; - $_SESSION['default_user'] = ''; - - $_SESSION['bd_type'] = ''; - $_SESSION['bd_host'] = ''; - $_SESSION['bd_user'] = ''; - $_SESSION['bd_password'] = ''; - $_SESSION['bd_base'] = ''; - $_SESSION['bd_prefix'] = ''; + // First, we try to get previous configurations + Minz_Configuration::register('system', + DATA_PATH . '/config.php', + DATA_PATH . '/config.default.php'); + $system_conf = Minz_Configuration::get('system'); + + $current_user = $system_conf->default_user; + Minz_Configuration::register('user', + USERS_PATH . '/' . $current_user . '/config.php', + USERS_PATH . '/_/config.default.php'); + $user_conf = Minz_Configuration::get('user'); + + // Then, we set $_SESSION vars + $_SESSION['title'] = $system_conf->title; + $_SESSION['old_entries'] = $user_conf->old_entries; + $_SESSION['mail_login'] = $user_conf->mail_login; + $_SESSION['default_user'] = $current_user; + + $db = $system_conf->db; + $_SESSION['bd_type'] = $db['type']; + $_SESSION['bd_host'] = $db['host']; + $_SESSION['bd_user'] = $db['user']; + $_SESSION['bd_password'] = $db['password']; + $_SESSION['bd_base'] = $db['base']; + $_SESSION['bd_prefix'] = $db['prefix']; $_SESSION['bd_error'] = ''; header('Location: index.php?step=4'); @@ -105,7 +118,7 @@ function saveStep1() { } function saveStep2() { - $user_default_config = Minz_Configuration::get('user'); + $user_default_config = Minz_Configuration::get('default_user'); if (!empty($_POST)) { $_SESSION['title'] = substr(trim(param('title', _t('gen.freshrss'))), 0, 25); $_SESSION['old_entries'] = param('old_entries', $user_default_config->old_entries); @@ -583,7 +596,7 @@ function printStep1() { } function printStep2() { - $user_default_config = Minz_Configuration::get('user'); + $user_default_config = Minz_Configuration::get('default_user'); ?>

@@ -709,7 +722,7 @@ function printStep2() { } function printStep3() { - $system_default_config = Minz_Configuration::get('system'); + $system_default_config = Minz_Configuration::get('default_system'); ?>

-- cgit v1.2.3 From 7925a5125b6a095cde4b2c92846dac384d66d20e Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 20 Jul 2015 15:59:33 +0200 Subject: Detect previous FreshRSS installation See https://github.com/FreshRSS/FreshRSS/issues/909 --- app/install.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index 75a211064..3312208c0 100644 --- a/app/install.php +++ b/app/install.php @@ -9,6 +9,7 @@ session_name('FreshRSS'); session_set_cookie_params(0, dirname(empty($_SERVER['REQUEST_URI']) ? '/' : dirname($_SERVER['REQUEST_URI'])), null, false, true); session_start(); +// TODO: use join_path() instead Minz_Configuration::register('default_system', DATA_PATH . '/config.default.php'); Minz_Configuration::register('default_user', USERS_PATH . '/_/config.default.php'); @@ -80,6 +81,7 @@ function saveLanguage() { } function saveStep1() { + // TODO: rename reinstall in install if (isset($_POST['freshrss-keep-reinstall']) && $_POST['freshrss-keep-reinstall'] === '1') { // We want to keep our previous installation of FreshRSS @@ -87,6 +89,7 @@ function saveStep1() { // with values from the previous installation // First, we try to get previous configurations + // TODO: use join_path() instead Minz_Configuration::register('system', DATA_PATH . '/config.php', DATA_PATH . '/config.default.php'); @@ -100,9 +103,11 @@ function saveStep1() { // Then, we set $_SESSION vars $_SESSION['title'] = $system_conf->title; + $_SESSION['auth_type'] = $system_conf->auth_type; $_SESSION['old_entries'] = $user_conf->old_entries; $_SESSION['mail_login'] = $user_conf->mail_login; $_SESSION['default_user'] = $current_user; + $_SESSION['passwordHash'] = $user_conf->passwordHash; $db = $system_conf->db; $_SESSION['bd_type'] = $db['type']; @@ -341,7 +346,30 @@ function checkStep1() { } function freshrss_already_installed() { - return false; + $conf_path = join_path(DATA_PATH, 'config.php'); + if (!file_exists($conf_path)) { + return false; + } + + // A configuration file already exists, we try to load it. + $system_conf = null; + try { + Minz_Configuration::register('system', $conf_path); + $system_conf = Minz_Configuration::get('system'); + } catch (Minz_FileNotExistException $e) { + return false; + } + + // ok, the global conf exists... but what about default user conf? + $current_user = $system_conf->default_user; + try { + Minz_Configuration::register('user', join_path(USERS_PATH, $current_user, 'config.php')); + } catch (Minz_FileNotExistException $e) { + return false; + } + + // ok, ok, default user exists too! + return true; } function checkStep2() { -- cgit v1.2.3 From 118e0ddd0a3dcd7e08d695567c6caa2d79d4b606 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 20 Jul 2015 16:12:21 +0200 Subject: Remove TODO (join_path and reinstall) See https://github.com/FreshRSS/FreshRSS/issues/909 --- app/install.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index 3312208c0..208bef0e9 100644 --- a/app/install.php +++ b/app/install.php @@ -9,9 +9,8 @@ session_name('FreshRSS'); session_set_cookie_params(0, dirname(empty($_SERVER['REQUEST_URI']) ? '/' : dirname($_SERVER['REQUEST_URI'])), null, false, true); session_start(); -// TODO: use join_path() instead -Minz_Configuration::register('default_system', DATA_PATH . '/config.default.php'); -Minz_Configuration::register('default_user', USERS_PATH . '/_/config.default.php'); +Minz_Configuration::register('default_system', join_path(DATA_PATH, 'config.default.php')); +Minz_Configuration::register('default_user', join_path(USERS_PATH, '_', 'config.default.php')); if (isset($_GET['step'])) { define('STEP',(int)$_GET['step']); @@ -81,24 +80,22 @@ function saveLanguage() { } function saveStep1() { - // TODO: rename reinstall in install - if (isset($_POST['freshrss-keep-reinstall']) && - $_POST['freshrss-keep-reinstall'] === '1') { + if (isset($_POST['freshrss-keep-install']) && + $_POST['freshrss-keep-install'] === '1') { // We want to keep our previous installation of FreshRSS // so we need to make next steps valid by setting $_SESSION vars // with values from the previous installation // First, we try to get previous configurations - // TODO: use join_path() instead Minz_Configuration::register('system', - DATA_PATH . '/config.php', - DATA_PATH . '/config.default.php'); + join_path(DATA_PATH, 'config.php'), + join_path(DATA_PATH, 'config.default.php')); $system_conf = Minz_Configuration::get('system'); $current_user = $system_conf->default_user; Minz_Configuration::register('user', - USERS_PATH . '/' . $current_user . '/config.php', - USERS_PATH . '/_/config.default.php'); + join_path(USERS_PATH, $current_user, 'config.php'), + join_path(USERS_PATH, '_', 'config.default.php')); $user_conf = Minz_Configuration::get('user'); // Then, we set $_SESSION vars @@ -611,7 +608,7 @@ function printStep1() {

- +
-- cgit v1.2.3 From 2c8b4f5a502cb387f5eccfcc38aa7434bd75637a Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 20 Jul 2015 16:27:10 +0200 Subject: Add translations TODO: german and czech translations See https://github.com/FreshRSS/FreshRSS/issues/909 --- app/i18n/cz/install.php | 3 +++ app/i18n/de/install.php | 3 +++ app/i18n/en/install.php | 3 +++ app/i18n/fr/install.php | 3 +++ app/install.php | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-) (limited to 'app/install.php') diff --git a/app/i18n/cz/install.php b/app/i18n/cz/install.php index 53257c84f..5f84d1cac 100644 --- a/app/i18n/cz/install.php +++ b/app/i18n/cz/install.php @@ -4,7 +4,9 @@ return array( 'action' => array( 'finish' => 'Dokončit instalaci', 'fix_errors_before' => 'Chyby prosím před přechodem na další krok opravte.', + 'keep_install' => 'Keep previous installation', // TODO: translate 'next_step' => 'Přejít na další krok', + 'reinstall' => 'Reinstall FreshRSS', // TODO: translate ), 'auth' => array( 'email_persona' => 'Email pro přihlášení
(pro Mozilla Persona)', @@ -31,6 +33,7 @@ return array( ), 'check' => array( '_' => 'Kontrola', + 'already_installed' => 'We have detected that FreshRSS is already installed!', // TODO: translate 'cache' => array( 'nok' => 'Zkontrolujte oprávnění adresáře ./data/cache. HTTP server musí mít do tohoto adresáře práva zápisu', 'ok' => 'Oprávnění adresáře cache jsou v pořádku.', diff --git a/app/i18n/de/install.php b/app/i18n/de/install.php index a5899bb52..6d937a638 100644 --- a/app/i18n/de/install.php +++ b/app/i18n/de/install.php @@ -4,7 +4,9 @@ return array( 'action' => array( 'finish' => 'Installation fertigstellen', 'fix_errors_before' => 'Bitte Fehler korrigieren, bevor zum nächsten Schritt gesprungen wird.', + 'keep_install' => 'Keep previous installation', // TODO: translate 'next_step' => 'Zum nächsten Schritt springen', + 'reinstall' => 'Reinstall FreshRSS', // TODO: translate ), 'auth' => array( 'email_persona' => 'Anmelde-E-Mail-Adresse
(für Mozilla Persona)', @@ -31,6 +33,7 @@ return array( ), 'check' => array( '_' => 'Überprüfungen', + 'already_installed' => 'We have detected that FreshRSS is already installed!', // TODO: translate 'cache' => array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/cache. Der HTTP-Server muss Schreibrechte besitzen.', 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/cache sind in Ordnung.', diff --git a/app/i18n/en/install.php b/app/i18n/en/install.php index d4137309a..80488ca4a 100644 --- a/app/i18n/en/install.php +++ b/app/i18n/en/install.php @@ -4,7 +4,9 @@ return array( 'action' => array( 'finish' => 'Complete installation', 'fix_errors_before' => 'Please fix errors before skipping to the next step.', + 'keep_install' => 'Keep previous installation', 'next_step' => 'Go to the next step', + 'reinstall' => 'Reinstall FreshRSS', ), 'auth' => array( 'email_persona' => 'Login email address
(for Mozilla Persona)', @@ -31,6 +33,7 @@ return array( ), 'check' => array( '_' => 'Checks', + 'already_installed' => 'We have detected that FreshRSS is already installed!', 'cache' => array( 'nok' => 'Check permissions on ./data/cache directory. HTTP server must have rights to write into', 'ok' => 'Permissions on cache directory are good.', diff --git a/app/i18n/fr/install.php b/app/i18n/fr/install.php index 245a20c56..6eca90458 100644 --- a/app/i18n/fr/install.php +++ b/app/i18n/fr/install.php @@ -4,7 +4,9 @@ return array( 'action' => array( 'finish' => 'Terminer l’installation', 'fix_errors_before' => 'Veuillez corriger les erreurs avant de passer à l’étape suivante.', + 'keep_install' => 'Garder l’ancienne configuration', 'next_step' => 'Passer à l’étape suivante', + 'reinstall' => 'Réinstaller FreshRSS', ), 'auth' => array( 'email_persona' => 'Adresse courriel de connexion
(pour Mozilla Persona)', @@ -31,6 +33,7 @@ return array( ), 'check' => array( '_' => 'Vérifications', + 'already_installed' => 'FreshRSS semble avoir déjà été installé !', 'cache' => array( 'nok' => 'Veuillez vérifier les droits sur le répertoire ./data/cache. Le serveur HTTP doit être capable d’écrire dedans', 'ok' => 'Les droits sur le répertoire de cache sont bons.', diff --git a/app/install.php b/app/install.php index 208bef0e9..61d2f5df9 100644 --- a/app/install.php +++ b/app/install.php @@ -605,7 +605,7 @@ function printStep1() { -

+

-- cgit v1.2.3 From 5d9b5f07feee3e388e747e5791cd91d1b98f55ef Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 20 Jul 2015 17:10:18 +0200 Subject: Ask confirmation before reinstallation See https://github.com/FreshRSS/FreshRSS/issues/909 --- app/install.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index 61d2f5df9..ebd785f65 100644 --- a/app/install.php +++ b/app/install.php @@ -609,9 +609,31 @@ function printStep1() { - - + + + + -- cgit v1.2.3