diff --git a/setup/class_setup.inc b/setup/class_setup.inc index dd16ee29105c32f45cb5139f7ac8cfe144b249c1..5efca8f88fb2d5f9b176abdf3013d572cda72cde 100644 --- a/setup/class_setup.inc +++ b/setup/class_setup.inc @@ -80,48 +80,20 @@ class setup implements FusionDirectoryDialog /* Save posted attributes */ public function readPost () { - /* Call readPost and update for current setup step */ + /* Call readPost for current setup step */ $this->o_steps[$this->i_current]->readPost(); - $this->o_steps[$this->i_current]->update(); - - /* Get attributes from setup step */ - $tmp = $this->o_steps[$this->i_current]->get_attributes(); - foreach ($tmp as $name => $value) { - $this->captured_values[$name] = $value; - } - - /* Set parent */ - foreach ($this->o_steps as $key => $value) { - $this->o_steps[$key]->parent = $this; - } /* Check if image button requests next page */ foreach ($_POST as $name => $value) { - if (preg_match("/^next_(x|y)/", $name)) { + if (preg_match('/^next_(x|y)/', $name)) { $_POST['next'] = TRUE; } - if (preg_match("/^last_(x|y)/", $name)) { + if (preg_match('/^last_(x|y)/', $name)) { $_POST['last'] = TRUE; } } - /* Display step error messages */ - $msgs = $this->o_steps[$this->i_current]->check(); - msg_dialog::displayChecks($msgs); - - for ($i = 0; $i < $this->i_steps; $i++) { - 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; - } - } - + /* Detect target step */ $step = -1; if (isset($_POST['setup_goto_step'])) { @@ -143,14 +115,49 @@ class setup implements FusionDirectoryDialog } } - if ($this->selectable_step($step)) { - $this->i_previous = $this->i_current; - $this->i_current = $step; - } + $this->i_previous = $this->i_current; + $this->i_current = $step; } public function update (): bool { + if (!$this->selectable_step($this->i_current)) { + $this->i_current = $this->i_previous; + } + + $this->o_steps[$this->i_previous]->update(); + + /* Get attributes from setup step */ + $tmp = $this->o_steps[$this->i_previous]->get_attributes(); + foreach ($tmp as $name => $value) { + $this->captured_values[$name] = $value; + } + + /* Set parent */ + foreach ($this->o_steps as $key => $value) { + $this->o_steps[$key]->parent = $this; + } + + /* Display step error messages */ + $msgs = $this->o_steps[$this->i_previous]->check(); + msg_dialog::displayChecks($msgs); + + for ($i = 0; $i < $this->i_steps; $i++) { + 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; + } + } + + if ($this->i_current != $this->i_previous) { + $this->o_steps[$this->i_current]->update(); + } return TRUE; } @@ -241,7 +248,7 @@ class setup implements FusionDirectoryDialog /* Check if the given step id is valid and selectable */ - function selectable_step ($id) + protected function selectable_step ($id): bool { if (isset($this->o_steps[$id]) && $this->o_steps[$id]->is_enabled()) { return TRUE; diff --git a/setup/class_setupStepLdap.inc b/setup/class_setupStepLdap.inc index 6deb3a435640a68c5087ff4dae6ac578334f748c..1745b6b48697a1262b577377229a029b94c21ac9 100644 --- a/setup/class_setupStepLdap.inc +++ b/setup/class_setupStepLdap.inc @@ -26,6 +26,9 @@ class setupStepLdap extends setupStep var $connect_id = FALSE; var $bind_id = FALSE; + private $lastBase = ''; + private $lastConnection = ''; + static function getAttributesInfo (): array { return [ @@ -128,17 +131,18 @@ class setupStepLdap extends setupStep 'base', TRUE ); } + $this->lastConnection = $this->connection; + $this->lastBase = $this->base; } public function update (): bool { - $base = $this->base; - $connection = $this->connection; parent::update(); - $this->connection = preg_replace("/\/$/", "", $this->connection); - if (($this->base != $base) || ($this->connection != $connection)) { + $this->connection = preg_replace('/\/$/', '', $this->connection); + if (($this->base != $this->lastBase) || ($this->connection != $this->lastConnection)) { $this->parent->disable_steps_from(($this->parent->step_name_to_id(get_class($this))) + 1); - if ($this->connection != $connection) { + $this->lastBase = $this->base; + if ($this->connection != $this->lastConnection) { $this->update_base_choices(); } } diff --git a/setup/class_setupStepMigrate.inc b/setup/class_setupStepMigrate.inc index 0fd4830b6df1d4ad163dd5cc5db4170cafda463d..a6c3faa391f515215cc49a935f3ff5134d7d9634 100644 --- a/setup/class_setupStepMigrate.inc +++ b/setup/class_setupStepMigrate.inc @@ -114,6 +114,11 @@ class StepMigrateDialog implements FusionDirectoryDialog { unset($this->check); } + + public function getInfos (): array + { + return $this->infos; + } } class StepMigrateCheck @@ -888,12 +893,20 @@ class setupStepMigrate extends setupStep $roledn = $tabObject->dn; } - $_POST['dialog_refresh'] = TRUE; - /* Creating user */ - $tabObject = objects::create('user'); - $tabObject->getBaseObject()->givenName = 'System'; - $tabObject->getBaseObject()->sn = 'Administrator'; + $infos = $checkobj->getInfos(); + $tabObject = objects::create('user'); + $baseObject = $tabObject->getBaseObject(); + $baseObject->givenName = 'System'; + $baseObject->sn = 'Administrator'; + $baseObject->uid = $infos['uid']; + $baseObject->userPassword = [ + '', + $infos['password'], + $infos['password2'], + '', + FALSE + ]; $tabObject->update(); $errors = $tabObject->save(); if (!empty($errors)) {