Upload via GUI (258 Dateien)

This commit is contained in:
2026-10-16 19:12:13 +00:00
parent 893bef356c
commit 491b87f468
50 changed files with 4601 additions and 0 deletions
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/common.php';
api_require_method('GET');
$staff = api_require_staff();
$pdo = get_db();
// department_id ist NULLable (fuer alle Abteilungen sichtbar) — dept_filter_sql() kann das nicht
// abbilden (es haengt ein UND an, wir brauchen aber "IS NULL ODER eigene Abteilung"), daher hier
// manuell gebaut.
$departmentIds = staff_department_ids($staff);
$deptFilter = '';
$deptParams = [];
if ($departmentIds !== null) {
if (count($departmentIds) === 0) {
$deptFilter = ' AND cr.department_id IS NULL';
} else {
$placeholders = implode(',', array_fill(0, count($departmentIds), '?'));
$deptFilter = " AND (cr.department_id IS NULL OR cr.department_id IN ({$placeholders}))";
$deptParams = $departmentIds;
}
}
$stmt = $pdo->prepare(
"SELECT cr.id, cr.title, cr.body, cr.department_id
FROM canned_responses cr
WHERE 1=1{$deptFilter}
ORDER BY cr.title"
);
$stmt->execute($deptParams);
$responses = array_map(fn(array $row) => [
'id' => (int) $row['id'],
'title' => $row['title'],
'body' => api_plain_text($row['body']),
'departmentId' => $row['department_id'] !== null ? (int) $row['department_id'] : null,
], $stmt->fetchAll());
api_json(['items' => $responses]);