From 43a2e13828f63ee4d17b748e22cfad9b17f75a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Wed, 27 Jun 2018 17:49:33 +0200 Subject: [PATCH] :ambulance: fix(setup) Show errors encountered when saving config from setup Also tidy up the code a bit. issue #5850 --- setup/class_setup.inc | 32 +++++++++----------------------- setup/class_setupStepConfig.inc | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/setup/class_setup.inc b/setup/class_setup.inc index 10f15707a..02f0b236e 100644 --- a/setup/class_setup.inc +++ b/setup/class_setup.inc @@ -122,32 +122,18 @@ class setup } } - /* display step error msgs */ + /* Display step error messages */ $msgs = $this->o_steps[$this->i_current]->check(); - foreach ($msgs as $msg) { - msg_dialog::display(_("Setup error"), $msg, ERROR_DIALOG); - } - - /* Check if step was selected */ - if (isset($_GET['step']) || isset($_POST['next']) || isset($_POST['last'])) { + msg_dialog::displayChecks($msgs); - /* check if current setup step is completed now - and activate the next step if possible */ - for ($i = 0; $i < $this->i_steps; $i++) { - if ($this->o_steps[$i]->is_completed()) { - if (isset($this->o_steps[($i + 1)])) { - $this->o_steps[($i + 1)]->set_enabled(); - } - } else { - $this->disable_steps_from($i + 1); - break; - } - } - } - - /* Disable all following steps, if one step isn't completed right now .*/ for ($i = 0; $i < $this->i_steps; $i++) { - if (!$this->o_steps[$i]->is_completed()) { + if ($this->o_steps[$i]->is_completed()) { + /* If step is completed, activate the next step if possible */ + if (isset($this->o_steps[($i + 1)])) { + $this->o_steps[($i + 1)]->set_enabled(); + } + } else { + /* Disable all following steps, if one step isn't completed right now */ $this->disable_steps_from($i + 1); break; } diff --git a/setup/class_setupStepConfig.inc b/setup/class_setupStepConfig.inc index 55a472f16..4f2f63dcf 100644 --- a/setup/class_setupStepConfig.inc +++ b/setup/class_setupStepConfig.inc @@ -96,6 +96,7 @@ class setupStepConfig extends configInLdap { global $config; parent::save_object(); + $this->is_completed = FALSE; $tmp = $this->check(); if (count($tmp) == 0) { /* Create root object if missing */ @@ -103,18 +104,25 @@ class setupStepConfig extends configInLdap $ldap->cd($config->current['BASE']); $ldap->create_missing_trees($config->current['BASE'], FALSE); if (!$ldap->success()) { - return msgPool::ldaperror($ldap->get_error(), $config->current['BASE'], 'create_missing_trees', get_class()); + msg_dialog::display( + _('LDAP error'), + msgPool::ldaperror($ldap->get_error(), $config->current['BASE'], 'create_missing_trees', get_class()), + LDAP_ERROR + ); + return; } /* Save in LDAP */ - $this->save(); + $errors = $this->save(); + if (!empty($errors)) { + msg_dialog::displayChecks($errors); + return; + } /* Reload config from LDAP */ $config->set_current($config->current['NAME']); session::global_un_set('plist'); load_plist(); $this->is_completed = TRUE; $this->parent->reBuildConfigStep(TRUE); - } else { - $this->is_completed = FALSE; } } -- GitLab