dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
configure_docs_access_20260728.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
18
19$base = dirname(__DIR__, 4);
20chdir($base);
21$_SERVER['REQUEST_URI'] = '/dbxapp-docs/';
22$_SERVER['HTTP_HOST'] = 'localhost';
23$_SERVER['HTTPS'] = 'on';
24$_SERVER['SCRIPT_NAME'] = '/dbxapp-docs/index.php';
25
26define('dbxSystem', 'dbxWebApp');
27define('dbxRunAsAdmin', 1);
28
29require $base . '/dbx/vendor/autoload.php';
30require_once $base . '/dbx/include/dbxKernel.php';
31require_once $base . '/dbx/modules/dbxSetup/include/dbxInstallationService.class.php';
32
34
35$db = dbx()->get_system_obj('dbxDB');
36$dd = dbx()->get_system_obj('dbxDD');
37$schema = array();
38
39foreach (array('dbxUser', 'dbxUser_groups') as $name) {
40 $dd->sync_dd_to_db('dbx', $name, 'reset');
41 $state = array();
42 for ($step = 0; $step < 1000; $step++) {
43 $state = $dd->sync_dd_to_db('dbx', $name, 'apply');
44 if (in_array((string)($state['status'] ?? ''), array('finished', 'error', 'cancelled'), true)) {
45 break;
46 }
47 }
48 $schema[$name] = $state;
49}
50
51$failed = array_filter(
52 $schema,
53 static fn(array $state): bool => ($state['status'] ?? '') !== 'finished'
54);
55if ($failed !== array()) {
56 throw new RuntimeException('Die Benutzer-DDs konnten nicht vollständig provisioniert werden.');
57}
58
59$installer = new dbxInstallationService($db, $dd);
60$groups = $installer->seedCoreGroups();
61$admin = $db->select1(
62 'dbx|dbxUser',
63 array('uname' => 'admin'),
64 array('id', 'uname', 'roles', 'status', 'is_confirm'),
65 0
66);
67
68if ((int)($admin['id'] ?? 0) <= 0) {
69 $password = (string)getenv('DBX_DOCS_ADMIN_PASSWORD');
70 $email = (string)getenv('DBX_DOCS_ADMIN_EMAIL');
71 if ($password === '' || $email === '') {
72 throw new RuntimeException(
73 'Admin fehlt. DBX_DOCS_ADMIN_PASSWORD und DBX_DOCS_ADMIN_EMAIL müssen lokal gesetzt sein.'
74 );
75 }
76 $installer->createAdmin($password, $email, 'de');
77 $admin = $db->select1(
78 'dbx|dbxUser',
79 array('uname' => 'admin'),
80 array('id', 'uname', 'roles', 'status', 'is_confirm'),
81 0
82 );
83}
84
85if (!dbx()->patch_local_config('dbxLogin', array('register' => '0'))) {
86 throw new RuntimeException('Die lokale Login-Konfiguration konnte nicht geschrieben werden.');
87}
88
89$binding = $db->get_dd_server_binding_info('dbx|dbxUser');
90$ok = (int)($admin['id'] ?? 0) > 0
91 && (int)($admin['status'] ?? 0) === 1
92 && str_contains((string)($admin['roles'] ?? ''), 'admin')
93 && (string)dbx()->get_config('dbxLogin', 'register') === '0';
94
95echo json_encode(array(
96 'ok' => $ok,
97 'schema' => $schema,
98 'groups' => $groups,
99 'admin' => array(
100 'present' => (int)($admin['id'] ?? 0) > 0,
101 'active' => (int)($admin['status'] ?? 0) === 1,
102 'confirmed' => (int)($admin['is_confirm'] ?? 0) === 1,
103 ),
104 'registration' => 'disabled',
105 'user_storage' => (string)($binding['resolved_server'] ?? ''),
106), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . PHP_EOL;
107
108exit($ok ? 0 : 1);
Reproduzierbare Erstinstallation aus DDs und idempotenten Seeds.
if($failed !==array()) $installer
if((int)( $admin[ 'id'] ?? 0)<=0) if(!dbx() ->patch_local_config('dbxLogin', array('register'=> '0'))) $binding
patch_local_config(string $modul, array $patch)
Fuehrt einen lokalen Konfigurationsausschnitt rekursiv zusammen.
Definition dbxApi.php:875
$_SERVER['REQUEST_METHOD']
exit
Definition index.php:146
DBX schema administration.