Dashboard Fach hinzufügen funktioniert in swe-b1-a-dev

This commit is contained in:
Kelvi Yawo Jules Agbessi Awuklu
2024-12-21 20:08:59 +01:00
committed by Matthias Grief
parent a04936f59e
commit 77e91ae393
119 changed files with 5374 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
require_once("../../classes/TopicData.php");
require_once("../../classes/Config.php");
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Validate and sanitize input
$displayName = htmlspecialchars($_POST['displayName']);
$subjectId = $_POST['subjectId'];
$description = $_POST['description'];
$icon = $_POST['icon'];
$article = $_POST['article'];
// Generate ID from displayName
$id = strtolower(preg_replace('/[^A-Za-z0-9]/', '', $displayName));
// Create topic
$topic = TopicData::createNew(
$id,
$subjectId,
$displayName,
$icon,
$description,
[], // empty related topics array
$article
);
if (!$topic || !$topic->save()) {
http_response_code(400);
echo json_encode(['success' => false, 'message' => 'Failed to create topic']);
exit();
}
echo json_encode(['success' => true]);