Die Zugriffspruefung lief bisher in 19 Dateien auf einen Fallback gegen die Legacy-Tabelle kl_Mitarbeiter (checkKaffeelisteAdmin/-Access). Der Zugang haengt jetzt ausschliesslich an der SaaS-Anmeldung. - Fallback-Bloecke in allen 19 Dateien entfernt, ebenso getUserName/getUserId - functions.php besteht nur noch aus der SaaS-Anmeldung; die per String zusammengebaute Abfrage "WHERE Email like '<eingabe>'" ist damit weg - config.php baut keine sqlsrv-Verbindung mehr auf, der Kompatibilitaetslayer lib/sqlsrv_mysql_compat.php ist verwaist und entfaellt - Auto-Login per DEV_AUTH_EMAIL gibt es nicht mehr: er meldete jeden Besucher an und machte damit den Login-Schutz unpruefbar. Angemeldet wird auch lokal ueber login.php; die Variable dient nur noch scripts/init-mysql-dev.php http-smoke war an die Golden-Master-Daten des Default-Mandanten gebunden und hatte deshalb sechs dauerhaft rote Pruefungen. Der Test legt sich jetzt einen eigenen Mandanten mit bekannten Salden an, meldet sich per HTTP an und raeumt danach auf. Geschuetzte Seiten werden nicht mehr ueber das Wort "Login" im Text geprueft, sondern ueber die tatsaechliche 302-Umleitung. http-smoke 27 PASS / 6 FAIL -> 33 PASS / 0 FAIL role-matrix 55 PASS / 0 FAIL -> unveraendert tenant-isolation 9 PASS / 1 FAIL -> 11 PASS / 1 FAIL (Altfehler) Ausserdem "keine Zugang" -> "keinen Zugang" in zwei Fehlermeldungen; der Rollentest erkannte die Ablehnung an genau diesem Tippfehler und wurde mitgezogen. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
106 lines
2.8 KiB
PHP
106 lines
2.8 KiB
PHP
<?php
|
|
|
|
include "functions.php";
|
|
require_once __DIR__ . "/app/ledger.php";
|
|
require_once __DIR__ . "/app/notices.php";
|
|
require_once __DIR__ . "/app/audit.php";
|
|
app_require_csrf();
|
|
include "header.php";
|
|
include "headerline.php";
|
|
include "nav.php";
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<!-- Banner -->
|
|
<section id="banner">
|
|
<div class="content">
|
|
|
|
<?php
|
|
|
|
$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){
|
|
|
|
echo "<h2>Kaffeeliste - Hinweise</h2>";
|
|
|
|
// Hinweis speichern oder als geloescht markieren
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$aktion = $_POST['aktion'] ?? 'speichern';
|
|
|
|
$actorUserId = $saasUser !== null ? (int)$saasUser['user_id'] : null;
|
|
|
|
if ($aktion === 'loeschen') {
|
|
$id = (int)($_POST['id'] ?? 0);
|
|
if ($id > 0 && notices_soft_delete($pdo, $tenantId, $id)) {
|
|
app_audit_log($pdo, $tenantId, $actorUserId, 'notice.deleted', 'notice', $id);
|
|
}
|
|
} else {
|
|
$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"
|
|
notices_create($pdo, $tenantId, (string)$nachricht, $gueltig_bis_sql, $actorUserId);
|
|
app_audit_log($pdo, $tenantId, $actorUserId, 'notice.created', 'notice', null, ['valid_until' => $gueltig_bis_sql]);
|
|
}
|
|
}
|
|
}
|
|
|
|
$hinweise = notices_fetch_all($pdo, $tenantId);
|
|
?>
|
|
|
|
|
|
<h2>Neuen Hinweis hinzufügen</h2>
|
|
<form method="post">
|
|
<input type="hidden" name="aktion" value="speichern">
|
|
<?php echo app_csrf_field(); ?>
|
|
<label>Nachricht:</label><br>
|
|
<textarea name="nachricht" required></textarea><br><br>
|
|
<label>Gültig bis:</label><br>
|
|
<input type="datetime-local" name="gueltig_bis" required><br><br>
|
|
<button type="submit">Speichern</button>
|
|
</form>
|
|
|
|
<h2>Alle Hinweise</h2>
|
|
<?php foreach ($hinweise as $hinweis): ?>
|
|
<div class="hinweis">
|
|
<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="<?php echo (int)$hinweis['id']; ?>">
|
|
<?php echo app_csrf_field(); ?>
|
|
<button type="submit">Löschen</button>
|
|
</form>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</body>
|
|
</html>
|
|
|
|
<?php
|
|
|
|
|
|
}else{
|
|
echo "<h2>Sie haben keinen Zugang zu dieser Webseite</h2>";
|
|
}
|
|
?>
|
|
|
|
</div>
|
|
</section>
|
|
|
|
<?php include "footer.php";
|
|
|
|
?>
|