M5: Hinweise auf tenant-scoped Notices umziehen, Mitgliederzugang auf Rollen umstellen
Hinweise: - Neue Tabelle notices (tenant-scoped, Soft-Delete via deleted_at) loest die global unscoped kl_hinweise als aktive Datenquelle ab; Migration uebernimmt einmalig aktuell gueltige kl_hinweise-Eintraege fuer den Default-Mandanten. kl_hinweise bleibt als Golden-Master-Referenz stehen. - hinweise.php und der Banner in header.php sind tenant-scoped umgestellt. Mitgliederverwaltung: - mitarbeiterverwalten.php verwaltet jetzt participants (tenant-scoped) statt der global unscoped kl_Mitarbeiter-Tabelle als primaere Quelle. Das behebt nebenbei ein Mandanten-Datenleck: jeder SaaS-Mandant mit Owner/Admin-Rolle haette zuvor die komplette Default-Mandanten- Mitgliederliste sehen und bearbeiten koennen. - Fuer den Default-Mandanten bleibt Dual-Write nach kl_Mitarbeiter bestehen, damit stricheintragen.php/einzahlung.php weiter funktionieren; andere Mandanten werden rein participant-nativ verwaltet. - Die Legacy-Administrator-Checkbox ist raus. Stattdessen kann ein Admin je Mitglied unabhaengig von Name/E-Mail einen Login-Zugang mit Rolle (member/treasurer/admin) gewaehren oder entziehen (saas_grant_participant_access / saas_revoke_participant_access). Einladung laeuft ueber den bestehenden Passwort-Reset-Mechanismus, Entzug setzt die Mitgliedschaft auf revoked statt sie zu loeschen. - Kompletter Flow live getestet: anlegen, Zugang gewaehren, Einladungsmail, Passwort setzen, Login, Rollenschutz, Zugang entziehen, Login-Sperre. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+32
-26
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
include "functions.php";
|
||||
require_once __DIR__ . "/app/ledger.php";
|
||||
require_once __DIR__ . "/app/notices.php";
|
||||
app_require_csrf();
|
||||
include "header.php";
|
||||
include "headerline.php";
|
||||
@@ -17,47 +19,51 @@ include "nav.php";
|
||||
|
||||
<?php
|
||||
|
||||
if(checkKaffeelisteAdmin($conn, $mailadress)){
|
||||
$pdo = app_db_pdo();
|
||||
$saasUser = saas_current_user($pdo);
|
||||
$tenantId = 0;
|
||||
$hasAccess = false;
|
||||
|
||||
if ($saasUser !== null && saas_user_has_role(['owner', 'admin'], $saasUser)) {
|
||||
$tenantId = (int)$saasUser['tenant_id'];
|
||||
$hasAccess = true;
|
||||
}
|
||||
|
||||
if (!$hasAccess && $saasUser === null && checkKaffeelisteAdmin($conn, $mailadress)) {
|
||||
$tenant = ledger_fetch_default_tenant($pdo);
|
||||
if ($tenant !== null) {
|
||||
$tenantId = (int)$tenant['id'];
|
||||
$hasAccess = true;
|
||||
}
|
||||
}
|
||||
|
||||
if($hasAccess){
|
||||
|
||||
echo "<h2>Kaffeeliste - Hinweise</h2>";
|
||||
|
||||
// Hinweis speichern oder löschen
|
||||
// Hinweis speichern oder als geloescht markieren
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$aktion = $_POST['aktion'] ?? 'speichern';
|
||||
|
||||
if ($aktion === 'loeschen') {
|
||||
$id = (int)($_POST['id'] ?? 0);
|
||||
if ($id > 0) {
|
||||
$stmt = sqlsrv_query($conn, "DELETE FROM kl_hinweise WHERE id = ?", [$id]);
|
||||
notices_soft_delete($pdo, $tenantId, $id);
|
||||
}
|
||||
} else {
|
||||
$nachricht = $_POST['nachricht'];
|
||||
$gueltig_bis = $_POST['gueltig_bis']; // z.B. "2025-09-03T14:00"
|
||||
$nachricht = $_POST['nachricht'] ?? '';
|
||||
$gueltig_bis = $_POST['gueltig_bis'] ?? ''; // z.B. "2025-09-03T14:00"
|
||||
$dt = DateTime::createFromFormat('Y-m-d\TH:i', $gueltig_bis);
|
||||
|
||||
if ($dt) {
|
||||
$gueltig_bis_sql = $dt->format('Y-m-d H:i:s'); // z.B. "2025-09-03 14:00:00"
|
||||
} else {
|
||||
die("Ungültiges Datumsformat");
|
||||
}
|
||||
|
||||
if (!empty($nachricht) && !empty($gueltig_bis_sql)) {
|
||||
|
||||
$stmt = sqlsrv_query($conn,
|
||||
"INSERT INTO kl_hinweise (nachricht, gueltig_bis) VALUES (?, ?)",
|
||||
[$nachricht, $gueltig_bis_sql]
|
||||
);
|
||||
|
||||
$createdByUserId = $saasUser !== null ? (int)$saasUser['user_id'] : null;
|
||||
notices_create($pdo, $tenantId, (string)$nachricht, $gueltig_bis_sql, $createdByUserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hinweise abrufen
|
||||
$hinweise = [];
|
||||
$stmt = sqlsrv_query($conn, "SELECT id, nachricht, gueltig_bis FROM kl_hinweise ORDER BY gueltig_bis DESC");
|
||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
$hinweise[] = $row;
|
||||
}
|
||||
$hinweise = notices_fetch_all($pdo, $tenantId);
|
||||
?>
|
||||
|
||||
|
||||
@@ -75,11 +81,11 @@ if(checkKaffeelisteAdmin($conn, $mailadress)){
|
||||
<h2>Alle Hinweise</h2>
|
||||
<?php foreach ($hinweise as $hinweis): ?>
|
||||
<div class="hinweis">
|
||||
<strong><?= htmlspecialchars($hinweis['nachricht']) ?></strong><br>
|
||||
<small>Gültig bis: <?= $hinweis['gueltig_bis']->format('d.m.Y H:i') ?></small><br>
|
||||
<strong><?php echo saas_html($hinweis['message']); ?></strong><br>
|
||||
<small>Gültig bis: <?php echo saas_html((new DateTimeImmutable($hinweis['valid_until']))->format('d.m.Y H:i')); ?></small><br>
|
||||
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" onsubmit="return confirm('Diesen Hinweis wirklich löschen?')">
|
||||
<input type="hidden" name="aktion" value="loeschen">
|
||||
<input type="hidden" name="id" value="<?= (int)$hinweis['id'] ?>">
|
||||
<input type="hidden" name="id" value="<?php echo (int)$hinweis['id']; ?>">
|
||||
<?php echo app_csrf_field(); ?>
|
||||
<button type="submit">Löschen</button>
|
||||
</form>
|
||||
@@ -99,6 +105,6 @@ if(checkKaffeelisteAdmin($conn, $mailadress)){
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php include "footer.php";
|
||||
<?php include "footer.php";
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user