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>
This commit is contained in:
92
module/tasks/lib/Request.php
Normal file
92
module/tasks/lib/Request.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
class TaskCertRequest
|
||||
{
|
||||
public static function method(): string
|
||||
{
|
||||
return strtoupper((string) ($_SERVER['REQUEST_METHOD'] ?? 'GET'));
|
||||
}
|
||||
|
||||
public static function isPost(): bool
|
||||
{
|
||||
return self::method() === 'POST';
|
||||
}
|
||||
|
||||
public static function postString(string $key, string $default = ''): string
|
||||
{
|
||||
$value = $_POST[$key] ?? $default;
|
||||
if (is_array($value)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return trim((string) $value);
|
||||
}
|
||||
|
||||
public static function postInt(string $key, int $default = 0): int
|
||||
{
|
||||
return (int) ($_POST[$key] ?? $default);
|
||||
}
|
||||
|
||||
public static function postArray(string $key): array
|
||||
{
|
||||
$value = $_POST[$key] ?? [];
|
||||
return is_array($value) ? $value : [];
|
||||
}
|
||||
|
||||
public static function postIntArray(string $key): array
|
||||
{
|
||||
$items = self::postArray($key);
|
||||
$result = [];
|
||||
|
||||
$collect = static function ($value) use (&$collect, &$result): void {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $nestedValue) {
|
||||
$collect($nestedValue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$itemInt = (int) $value;
|
||||
if ($itemInt > 0) {
|
||||
$result[] = $itemInt;
|
||||
}
|
||||
};
|
||||
|
||||
foreach ($items as $item) {
|
||||
$collect($item);
|
||||
}
|
||||
|
||||
return array_values(array_unique($result));
|
||||
}
|
||||
|
||||
public static function queryString(string $key, string $default = ''): string
|
||||
{
|
||||
$value = $_GET[$key] ?? $default;
|
||||
if (is_array($value)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return trim((string) $value);
|
||||
}
|
||||
|
||||
public static function queryInt(string $key, int $default = 0): int
|
||||
{
|
||||
return (int) ($_GET[$key] ?? $default);
|
||||
}
|
||||
|
||||
public static function jsonBody(): array
|
||||
{
|
||||
$raw = file_get_contents('php://input');
|
||||
if ($raw === false || $raw === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
$decoded = json_decode($raw, true);
|
||||
if (!is_array($decoded)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user