Commit 43a2e138 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(setup) Show errors encountered when saving config from setup

Also tidy up the code a bit.

issue #5850
Showing with 21 additions and 27 deletions
+21 -27
......@@ -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;
}
......
......@@ -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;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment