Upload via GUI (364 Dateien)
This commit is contained in:
@@ -8,6 +8,9 @@ declare(strict_types=1);
|
||||
* POST /api/public/v1/tickets.php Ticket lösen (Recht "Tickets anlegen")
|
||||
* JSON: { "action": "resolve", "number", "email", "message"? } nur für Tickets, die über die API angelegt wurden, mit passender E-Mail-Adresse
|
||||
* GET /api/public/v1/tickets.php?number=…&email=… Status + öffentlicher Verlauf (Recht "Tickets lesen")
|
||||
* GET /api/public/v1/tickets.php?topics=1 Öffentliche Hilfethemen (Recht "Tickets anlegen")
|
||||
* GET /api/public/v1/tickets.php?form=1&helpTopicId=… Kundenformular samt eigener Felder (Recht "Tickets anlegen")
|
||||
* Beim Anlegen nimmt "fields": { "<Feld-ID>": "Wert", … } die Angaben dieses Formulars entgegen (Pflichtfelder werden geprüft).
|
||||
*
|
||||
* Authentifizierung: Header "X-API-Key: dh_…" oder "Authorization: Bearer dh_…".
|
||||
* Schlüssel verwaltet ein Administrator unter Verwalten → API-Schlüssel.
|
||||
@@ -34,7 +37,12 @@ $key = trim((string) ($_SERVER['HTTP_X_API_KEY'] ?? ''));
|
||||
if ($key === '' && preg_match('/^Bearer\s+(\S+)$/i', (string) ($_SERVER['HTTP_AUTHORIZATION'] ?? ''), $m)) $key = $m[1];
|
||||
$pdo = get_db();
|
||||
$apiKey = $key !== '' ? api_key_verify($pdo, $key, client_ip()) : null;
|
||||
if (!$apiKey) public_api_fail(401, 'UNAUTHENTICATED', 'Ein gültiger API-Schlüssel ist erforderlich (Header X-API-Key).');
|
||||
if (!$apiKey) {
|
||||
if ($key !== '' && api_key_ip_blocked($pdo, $key, client_ip())) {
|
||||
public_api_fail(401, 'IP_NOT_ALLOWED', 'Der Schlüssel ist gültig, aber für die IP-Adresse ' . client_ip() . ' nicht freigegeben. Diese Adresse bei „Erlaubte IPs“ des Schlüssels eintragen (oder das Feld leer lassen).');
|
||||
}
|
||||
public_api_fail(401, 'UNAUTHENTICATED', 'Ein gültiger API-Schlüssel ist erforderlich (Header X-API-Key).');
|
||||
}
|
||||
|
||||
if ($method === 'POST') {
|
||||
if (!$apiKey['can_create_tickets']) public_api_fail(403, 'FORBIDDEN', 'Dieser Schlüssel darf keine Tickets anlegen.');
|
||||
@@ -80,6 +88,28 @@ if ($method === 'POST') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// GET ?topics=1 (Hilfethemen) und GET ?form=1&helpTopicId=…|departmentId=… (Kundenformular mit eigenen Feldern) für Website-Formulare.
|
||||
// Das ist dasselbe, was Kunden im Kundenportal sehen; es braucht das Recht "Tickets anlegen".
|
||||
if (isset($_GET['topics']) || isset($_GET['form'])) {
|
||||
if (!$apiKey['can_create_tickets']) public_api_fail(403, 'FORBIDDEN', 'Dieser Schlüssel darf keine Tickets anlegen.');
|
||||
if (isset($_GET['topics'])) {
|
||||
echo json_encode(['topics' => array_map(fn(array $t) => [
|
||||
'id' => (int) $t['id'], 'name' => (string) $t['name'], 'path' => (string) $t['path'], 'depth' => (int) $t['depth'],
|
||||
'parentId' => !empty($t['parent_id']) ? (int) $t['parent_id'] : null, 'departmentId' => (int) $t['department_id'],
|
||||
], help_topic_options($pdo, true))], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
try {
|
||||
$topicId = am_int_or_null($_GET, 'helpTopicId');
|
||||
$deptId = am_int_or_null($_GET, 'departmentId');
|
||||
$def = public_form_definition($pdo, $topicId, $topicId === null ? ($deptId ?: (int) get_setting('default_department_id', '1')) : $deptId);
|
||||
} catch (AdminModelException $e) {
|
||||
public_api_fail($e->httpStatus(), $e->errorCode(), $e->getMessage());
|
||||
}
|
||||
echo json_encode(['form' => public_form_payload($def)], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
// GET: Status eines Tickets (nur mit passender E-Mail-Adresse des Anfragenden)
|
||||
if (!$apiKey['can_read_tickets']) public_api_fail(403, 'FORBIDDEN', 'Dieser Schlüssel darf keine Tickets lesen.');
|
||||
$number = trim((string) ($_GET['number'] ?? ''));
|
||||
|
||||
Reference in New Issue
Block a user