From c04daeefc20f51dac2278dfed9fe2ed5035a17d8 Mon Sep 17 00:00:00 2001 From: rMalie Date: Fri, 3 Feb 2012 10:43:55 +0000 Subject: [PATCH] // Add a link to restart installer if an error occured + session protection on reinstallation --- install-dev/classes/session.php | 6 ++++++ install-dev/controllers/http/process.php | 16 ++++++++++++++- install-dev/theme/js/process.js | 1 + install-dev/theme/view.css | 25 ++++++++++++++++++++++-- install-dev/theme/views/process.phtml | 5 +++++ 5 files changed, 50 insertions(+), 3 deletions(-) diff --git a/install-dev/classes/session.php b/install-dev/classes/session.php index 38869f6dc..7d4025811 100644 --- a/install-dev/classes/session.php +++ b/install-dev/classes/session.php @@ -45,6 +45,12 @@ class InstallSession session_start(); } + public function clean() + { + foreach ($_SESSION as $k => $v) + unset($_SESSION[$k]); + } + public function &__get($varname) { if (isset($_SESSION[$varname])) diff --git a/install-dev/controllers/http/process.php b/install-dev/controllers/http/process.php index 6d3050363..3e6c04bf7 100644 --- a/install-dev/controllers/http/process.php +++ b/install-dev/controllers/http/process.php @@ -76,6 +76,9 @@ class InstallControllerHttpProcess extends InstallControllerHttp if (file_exists(_PS_ROOT_DIR_.'/'.self::SETTINGS_FILE)) require_once _PS_ROOT_DIR_.'/'.self::SETTINGS_FILE; + if (!$this->session->process_validated) + $this->session->process_validated = array(); + if (Tools::getValue('generateSettingsFile')) $this->processGenerateSettingsFile(); else if (Tools::getValue('installDatabase') && !empty($this->session->process_validated['generateSettingsFile'])) @@ -94,7 +97,13 @@ class InstallControllerHttpProcess extends InstallControllerHttp { // With no parameters, we consider that we are doing a new install, so session where the last process step // was stored can be cleaned - $this->session->process_validated = array(); + if (Tools::getValue('restart')) + $this->session->process_validated = array(); + else if (!Tools::getValue('submitNext')) + { + $this->session->clean(); + Tools::redirect('index.php'); + } } } @@ -225,6 +234,11 @@ class InstallControllerHttpProcess extends InstallControllerHttp $this->model_install->installTheme(); if ($this->model_install->getErrors()) $this->ajaxJsonAnswer(false, $this->model_install->getErrors()); + + // If last step is fine, we store the fact PrestaShop is installed + $this->session->last_step = 'configure'; + $this->session->step = 'configure'; + $this->ajaxJsonAnswer(true); } diff --git a/install-dev/theme/js/process.js b/install-dev/theme/js/process.js index d11a224e5..413b54fa8 100644 --- a/install-dev/theme/js/process.js +++ b/install-dev/theme/js/process.js @@ -78,6 +78,7 @@ function install_error(step, errors) current_step = 0; is_installing = false; + $('#error_process').show(); $('#process_step_'+step.key).show().addClass('fail'); $('#progress_bar .total .progress').stop().css('width', '0px'); $('#progress_bar .installing').hide(); diff --git a/install-dev/theme/view.css b/install-dev/theme/view.css index 1710df2d9..f2184ad62 100644 --- a/install-dev/theme/view.css +++ b/install-dev/theme/view.css @@ -693,7 +693,7 @@ ul#optional_update {list-style-type:none;} /* STEP 5 ******************************************/ #install_process_form{ - height: 260px; + min-height: 260px; } #progress_bar { display: none; @@ -763,7 +763,28 @@ ul#optional_update {list-style-type:none;} #progress_bar ol.process_list li .error_log li { padding: 3px; } - + +#error_process{ + padding: 5px; + background-color: #FBE8D6; + border: 1px solid #666666; + margin-left: 37px; + margin-bottom: 20px; + display: none; +} + #error_process h3{ + color: red; + } + #error_process p{ + margin-left: 20px; + } + #error_process p a{ + font-weight: bold; + } + #error_process p a:hover{ + text-decoration: underline; + } + #install_process_success { display: none; } diff --git a/install-dev/theme/views/process.phtml b/install-dev/theme/views/process.phtml index 78e2776a9..caab38e46 100644 --- a/install-dev/theme/views/process.phtml +++ b/install-dev/theme/views/process.phtml @@ -25,6 +25,11 @@ var process_percent = process_steps) ?>; + +
+

l('An error occured during installation ...') ?>

+

l('You can use the links on the left column to go back to the previous steps, or restart the installation process by clicking here.', 'index.php?restart=true') ?>

+