diff --git a/include/nc_connector_wizard_db_bridge.inc.php b/include/nc_connector_wizard_db_bridge.inc.php new file mode 100644 index 0000000..f7c3b85 --- /dev/null +++ b/include/nc_connector_wizard_db_bridge.inc.php @@ -0,0 +1,158 @@ +'Nextcloud wurde gefunden. Für den Datenzugriff wird eine separate Reader-Verbindung benötigt.'); + } + + try + { + bratonien_tools_nc_wizard_finish_data_access($state); + } + catch (Throwable $e) + { + $state['technical_complete'] = false; + $state['technical_stage'] = 'database_details'; + $state['technical_error'] = $e->getMessage(); + } + + bratonien_tools_nc_wizard_store($state); + + if ($state['technical_stage'] === 'database_details') + { + return array('message'=>'Nextcloud wurde gefunden. Die bekannte Reader-Verbindung konnte noch nicht vollständig bestätigt werden.'); + } + if ($state['technical_stage'] === 'mounts') + { + return array('message'=>'Nextcloud und Datenzugriff wurden bestätigt. Ein Speicherort muss noch zugeordnet werden.'); + } + + return array('message'=>'Nextcloud und die gespeicherte Reader-Verbindung wurden erfolgreich bestätigt.'); +} + +function bratonien_tools_nc_wizard_save_technical_with_known_database() +{ + $state = bratonien_tools_nc_wizard_state(); + if (empty($state['scan_ok'])) throw new RuntimeException('Bitte zuerst Nextcloud erfolgreich scannen.'); + + if (trim((string)($state['db_user'] ?? '')) === '' || (string)($state['_db_password'] ?? '') === '') + { + bratonien_tools_nc_wizard_apply_known_database_profile($state); + } + + if (trim((string)($state['db_user'] ?? '')) === '' || (string)($state['_db_password'] ?? '') === '') + { + throw new RuntimeException('Für diese Nextcloud sind noch keine Datenbank-Reader-Zugangsdaten bekannt. Nextcloud-Benutzer und -Passwort werden dafür bewusst nicht verwendet.'); + } + + $state['db_host'] = trim((string)($_POST['nc_wizard_db_host'] ?? $state['db_host'])); + $state['db_port'] = (string)max(1, min(65535, (int)($_POST['nc_wizard_db_port'] ?? $state['db_port']))); + $state['db_database'] = trim((string)($_POST['nc_wizard_db_database'] ?? $state['db_database'])); + $state['technical_stage'] = 'database_details'; + bratonien_tools_nc_wizard_store($state); + + if ($state['db_host'] === '' || $state['db_database'] === '') throw new RuntimeException('Die Adresse der Datenbank ist noch unvollständig.'); + + try + { + bratonien_tools_nc_wizard_finish_data_access($state); + bratonien_tools_nc_wizard_store($state); + + return array( + 'message'=>$state['technical_complete'] + ? 'Datenzugriff wurde erfolgreich geprüft.' + : 'Datenzugriff funktioniert. Ein Speicherort muss noch bestätigt werden.' + ); + } + catch (Throwable $e) + { + $state['technical_error'] = $e->getMessage(); + $state['technical_stage'] = 'database_details'; + bratonien_tools_nc_wizard_store($state); + throw $e; + } +}