Consolidates the previously separate omsorgapp and omsorgCore repos (each had their own nested .git with GitHub history) plus the old root-level website/mitarbeiter-app into a single monorepo, matching the structure already documented in the root CLAUDE.md. Also moves the PHP employee app aside as omsorgWeb/mitarbeiter-app-legacy/ to serve as a template for a ground-up rewrite. Fixes .gitignore in the same pass: the config-secrets/uploads/data patterns were unanchored (relative to repo root, not depth-agnostic), so they silently stopped matching once the app moved under omsorgWeb/. Patterns are now **/-prefixed and cover both mitarbeiter-app and mitarbeiter-app-legacy, keeping DB/SMTP credentials and uploaded employee documents out of version control. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
43 lines
924 B
PHP
43 lines
924 B
PHP
<?php
|
|
require_once __DIR__ . '/../lib/auth.php';
|
|
require_login();
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
header('Location: ../pages/dokumentenarchiv.php');
|
|
exit;
|
|
}
|
|
|
|
$id = (int) ($_POST['id'] ?? 0);
|
|
if ($id <= 0) {
|
|
http_response_code(400);
|
|
echo 'Ungültige Anfrage.';
|
|
exit;
|
|
}
|
|
|
|
$stmt = db()->prepare('SELECT * FROM dokumente WHERE id = ?');
|
|
$stmt->execute([$id]);
|
|
$doc = $stmt->fetch();
|
|
|
|
if (!$doc) {
|
|
http_response_code(404);
|
|
echo 'Dokument nicht gefunden.';
|
|
exit;
|
|
}
|
|
|
|
$user = current_user();
|
|
if ((int) $doc['user_id'] !== (int) $user['id'] && !is_admin()) {
|
|
http_response_code(403);
|
|
echo 'Keine Berechtigung.';
|
|
exit;
|
|
}
|
|
|
|
$file_path = dirname(__DIR__) . '/uploads/' . $doc['filename'];
|
|
if (is_file($file_path)) {
|
|
unlink($file_path);
|
|
}
|
|
|
|
db()->prepare('DELETE FROM dokumente WHERE id = ?')->execute([$id]);
|
|
|
|
header('Location: ../pages/dokumentenarchiv.php?deleted=1');
|
|
exit;
|