Files
awo-hamburg-intranet/module/tasks/lib/Response.php
Moritz Weinmann 743476f64a Module tasks + knowledgecenter_update aus Kundenprojekt übernehmen (bereinigt)
Beide Module wurden aus einem anderen Kundenprojekt kopiert und bereinigt:

Knowledgecenter:
- Bild-Cache (1.985 Dateien) geleert, Ordnerstruktur mit .gitkeep behalten
- Files-Gallery-Lizenzschlüssel entfernt (config.php)
- Kundenspezifische Kategorien gelöscht: Teil I/II/III QM-Struktur,
  nummerierte QM-Kapitel, Gremien (Präsidium/Finanzausschuss/Landesausschuss),
  Sitzungsservice-Serie, Protokoll-Abteilungen, Testeinträge
- 56 generische Kategorien bleiben (Downloads, Onboarding, Personalthemen …)

Tasks:
- Alle Betriebsdaten gelöscht (114 Tasks, 914 Submissions, 579 Assignments)
- Task-Definitionen und Verlinkungen geleert
- Kategoriestruktur bleibt (Allgemein, IT, Personal, Buchhaltung …)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 09:20:02 +02:00

56 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
class TaskCertResponse
{
public static function json(array $payload, int $statusCode = 200, bool $terminate = true): void
{
$isFailurePayload = isset($payload['success']) && (bool) $payload['success'] === false;
if ($statusCode >= 400 || $isFailurePayload) {
TaskCertLogger::warning('JSON response with error status', [
'status_code' => $statusCode,
'request_method' => (string) ($_SERVER['REQUEST_METHOD'] ?? ''),
'request_uri' => (string) ($_SERVER['REQUEST_URI'] ?? ''),
'error' => (string) ($payload['error'] ?? ''),
]);
}
http_response_code($statusCode);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
if ($terminate) {
exit;
}
}
public static function redirect(string $url, int $statusCode = 302): void
{
http_response_code($statusCode);
header('Location: ' . $url);
exit;
}
public static function error(string $message, int $statusCode = 400, bool $asJson = true): void
{
TaskCertLogger::warning('HTTP error response', [
'status_code' => $statusCode,
'request_method' => (string) ($_SERVER['REQUEST_METHOD'] ?? ''),
'request_uri' => (string) ($_SERVER['REQUEST_URI'] ?? ''),
'as_json' => $asJson ? 1 : 0,
'message' => $message,
]);
if ($asJson) {
self::json([
'success' => false,
'error' => $message,
], $statusCode, true);
}
http_response_code($statusCode);
echo htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
exit;
}
}