From 7c664f0a6bc72ff95116d6ef4489c51ef9d4c90a Mon Sep 17 00:00:00 2001 From: M_Viper Date: Thu, 5 Nov 2026 21:21:27 +0000 Subject: [PATCH] Upload via GUI (452 Dateien) --- DeskHub-Webseite/api/staff/v1/availability.php | 4 ++-- DeskHub-Webseite/api/staff/v1/banlist.php | 2 +- DeskHub-Webseite/api/staff/v1/common.php | 7 ++----- DeskHub-Webseite/api/staff/v1/mail_fetch.php | 1 + DeskHub-Webseite/api/staff/v1/queues.php | 2 +- DeskHub-Webseite/api/staff/v1/report_builder.php | 2 +- DeskHub-Webseite/version.php | 2 +- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/DeskHub-Webseite/api/staff/v1/availability.php b/DeskHub-Webseite/api/staff/v1/availability.php index 55efd547..c6b089a6 100644 --- a/DeskHub-Webseite/api/staff/v1/availability.php +++ b/DeskHub-Webseite/api/staff/v1/availability.php @@ -63,8 +63,8 @@ if (!in_array($newStatus, AVAILABILITY_STATUSES, true)) { // Ein Admin darf den Status eines anderen Mitarbeiters setzen (staffId), alle anderen nur den eigenen $targetId = (int) $staff['id']; if (isset($body['staffId']) && (int) $body['staffId'] !== $targetId) { - if (($staff['role'] ?? '') !== 'admin') { - api_error(403, 'FORBIDDEN', 'Nur Administratoren dürfen den Status anderer Mitarbeiter ändern.'); + if (!has_permission($staff, 'manage_availability')) { + api_error(403, 'FORBIDDEN', 'Für den Status anderer Mitarbeiter fehlt die erforderliche Berechtigung.'); } $targetId = (int) $body['staffId']; $exists = $pdo->prepare('SELECT COUNT(*) FROM staff WHERE id = ? AND is_active = 1'); diff --git a/DeskHub-Webseite/api/staff/v1/banlist.php b/DeskHub-Webseite/api/staff/v1/banlist.php index 9fec42af..200bedbb 100644 --- a/DeskHub-Webseite/api/staff/v1/banlist.php +++ b/DeskHub-Webseite/api/staff/v1/banlist.php @@ -4,7 +4,7 @@ require_once __DIR__ . '/common.php'; api_require_method('GET', 'POST'); $staff = api_require_staff(); -api_require_admin($staff); +api_require_admin_or_permission($staff, 'manage_banlist'); $pdo = get_db(); if ($_SERVER['REQUEST_METHOD'] === 'GET') { diff --git a/DeskHub-Webseite/api/staff/v1/common.php b/DeskHub-Webseite/api/staff/v1/common.php index 304d4438..5cbbf41c 100644 --- a/DeskHub-Webseite/api/staff/v1/common.php +++ b/DeskHub-Webseite/api/staff/v1/common.php @@ -170,10 +170,7 @@ function api_require_staff(): array function api_staff_payload(array $staff): array { - $permissionNames = array_merge([ - 'reply_ticket', 'close_ticket', 'post_note', 'assign_ticket', 'transfer_ticket', - 'create_ticket', 'view_reports', - ], array_keys(admin_section_permissions())); + $permissionNames = array_keys(permission_labels()); // alle Rechte des Katalogs (includes/permissions.php) $permissions = []; foreach ($permissionNames as $permission) { $permissions[$permission] = has_permission($staff, $permission); @@ -289,7 +286,7 @@ function api_ticket_summary(array $ticket): array // (überfällig)") – bewusst serverseitig über dieselbe time_until()-Funktion wie im // Web berechnet, statt das Datumsformat in Kotlin nachzubauen (siehe die Lehren aus // den PHP-Datums-Bugs dieser Session: eine einzige Quelle der Wahrheit fürs Format). - 'dueLabel' => !empty($ticket['sla_paused_at']) && ticket_sla_is_paused_status((string) $ticket['status']) ? 'Pausiert' : (!empty($ticket['resolution_due_at']) ? time_until($ticket['resolution_due_at']) : null), + 'dueLabel' => in_array($ticket['status'], ['resolved', 'closed'], true) ? null : (!empty($ticket['sla_paused_at']) && ticket_sla_is_paused_status((string) $ticket['status']) ? 'Pausiert' : (!empty($ticket['resolution_due_at']) ? time_until($ticket['resolution_due_at']) : null)), 'isSpam' => !empty($ticket['is_spam']), 'createdAt' => $ticket['created_at'], 'updatedAt' => $ticket['updated_at'], diff --git a/DeskHub-Webseite/api/staff/v1/mail_fetch.php b/DeskHub-Webseite/api/staff/v1/mail_fetch.php index 826f7bdc..bc4743eb 100644 --- a/DeskHub-Webseite/api/staff/v1/mail_fetch.php +++ b/DeskHub-Webseite/api/staff/v1/mail_fetch.php @@ -9,6 +9,7 @@ require_once __DIR__ . '/../../../includes/mail_fetch_manual.php'; */ api_require_method('POST'); $staff = api_require_staff(); +api_require_permission($staff, 'fetch_mail'); $pdo = get_db(); $r = mail_fetch_manual($pdo); audit_log((int) $staff['id'], 'E-Mail-Abruf von Hand gestartet über die App (' . $r['processed'] . ' E-Mail(s))'); diff --git a/DeskHub-Webseite/api/staff/v1/queues.php b/DeskHub-Webseite/api/staff/v1/queues.php index cdac6b6c..cd6926c6 100644 --- a/DeskHub-Webseite/api/staff/v1/queues.php +++ b/DeskHub-Webseite/api/staff/v1/queues.php @@ -22,7 +22,7 @@ $action = $body['action'] ?? ''; try { if ($action === 'save') { - $id = queue_create($pdo, (int) $staff['id'], (string) ($body['name'] ?? ''), (array) ($body['filters'] ?? []), !empty($body['isShared'])); + $id = queue_create($pdo, (int) $staff['id'], (string) ($body['name'] ?? ''), (array) ($body['filters'] ?? []), !empty($body['isShared']) && has_permission($staff, 'share_views')); api_json(['id' => $id]); } if ($action === 'delete') { diff --git a/DeskHub-Webseite/api/staff/v1/report_builder.php b/DeskHub-Webseite/api/staff/v1/report_builder.php index 82a11b4f..c2c58751 100644 --- a/DeskHub-Webseite/api/staff/v1/report_builder.php +++ b/DeskHub-Webseite/api/staff/v1/report_builder.php @@ -38,7 +38,7 @@ if ($action === 'save') { $cfg = report_clean_config($pdo, (array) ($body['config'] ?? [])); $now = db_now(); $pdo->prepare('INSERT INTO saved_reports (staff_id, name, config, is_shared, created_at, updated_at) VALUES (?,?,?,?,?,?)') - ->execute([$staff['id'], mb_substr($name, 0, 120), json_encode($cfg, JSON_UNESCAPED_UNICODE), !empty($body['isShared']) ? 1 : 0, $now, $now]); + ->execute([$staff['id'], mb_substr($name, 0, 120), json_encode($cfg, JSON_UNESCAPED_UNICODE), (!empty($body['isShared']) && has_permission($staff, 'share_views')) ? 1 : 0, $now, $now]); api_json(['id' => (int) $pdo->lastInsertId()]); } if ($action === 'delete') { diff --git a/DeskHub-Webseite/version.php b/DeskHub-Webseite/version.php index 8a1a72c1..938c812c 100644 --- a/DeskHub-Webseite/version.php +++ b/DeskHub-Webseite/version.php @@ -1,7 +1,7 @@