Löschen von Themen und Fächern eingebaut
This commit is contained in:
@@ -64,34 +64,47 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$errors["article"] = "Bitte geben Sie einen Erklärtext an.";
|
||||
}
|
||||
|
||||
if(!isset($_POST['submit']) || !($_POST['submit'] == "Speichern" || $_POST['submit'] == "Thema löschen")) {
|
||||
$errors["submit"] = "Ungültig abgeschickt!";
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$newTopic = false;
|
||||
|
||||
$relatedTopics = array();
|
||||
foreach (explode(",", $_POST['relatedTopics']) as $relatedTopic) {
|
||||
$relatedTopic = trim($relatedTopic);
|
||||
if($relatedTopic == "") {
|
||||
continue;
|
||||
}
|
||||
$relatedTopics[] = $relatedTopic;
|
||||
}
|
||||
|
||||
if(isset($allSubjects[$_POST['subjectId']]->getTopics()[$_POST['id']])) {
|
||||
$newTopic = $allSubjects[$_POST['subjectId']]->getTopics()[$_POST['id']];
|
||||
|
||||
$newTopic->setDisplayName($_POST['displayName']);
|
||||
$newTopic->setSubjectId($_POST['subjectId']);
|
||||
$newTopic->setDescription($_POST['description']);
|
||||
$newTopic->setIcon($_POST['icon']);
|
||||
|
||||
$relatedTopics = array();
|
||||
foreach (explode(",", $_POST['relatedTopics']) as $relatedTopic) {
|
||||
$relatedTopic = trim($relatedTopic);
|
||||
if($relatedTopic == "") {
|
||||
continue;
|
||||
}
|
||||
$relatedTopics[] = $relatedTopic;
|
||||
}
|
||||
$newTopic->setRelatedTopics($relatedTopics);
|
||||
$newTopic->setArticle($_POST['article']);
|
||||
} else {
|
||||
$newTopic = TopicData::createNew($_POST['id'], $_POST['subjectId'], $_POST['displayName'], $_POST['icon'], $_POST['description'], $_POST['relatedTopics'], $_POST['article']);
|
||||
$newTopic = TopicData::createNew($_POST['id'], $_POST['subjectId'], $_POST['displayName'], $_POST['icon'], $_POST['description'], $relatedTopics, $_POST['article']);
|
||||
}
|
||||
|
||||
if(!$newTopic) {
|
||||
$errors["error"] = "Fehler beim Speichern des Themas.";
|
||||
} else {
|
||||
$newTopic->save();
|
||||
header("Location: " . "topic.php?subject=" . $newTopic->getSubjectId() . "&topic=" . $newTopic->getId());
|
||||
if($_POST['submit'] == "Thema löschen") {
|
||||
$newTopic->delete();
|
||||
header("Location: " . "subject.php?subject=" . $_POST['subjectId']);
|
||||
} else {
|
||||
$newTopic->save();
|
||||
header("Location: " . "topic.php?subject=" . $newTopic->getSubjectId() . "&topic=" . $newTopic->getId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,15 +223,13 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
<div id="contentPreview" class="content-text prose prose-lg max-w-none bg-white p-6 rounded-lg shadow-sm"></div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-4">
|
||||
<button type="button" onclick="closeModal()"
|
||||
class="px-4 py-2 text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200">
|
||||
Abbrechen
|
||||
</button>
|
||||
<button type="submit"
|
||||
class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
|
||||
Speichern
|
||||
</button>
|
||||
<div class="flow-root gap-4">
|
||||
<input type="submit" value="Thema löschen" name="submit"
|
||||
class="float-left px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-gray-200">
|
||||
<input type="submit" value="Speichern" name="submit"
|
||||
class="float-right px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
|
||||
<input type="button" value="Abbrechen" onclick="history.back()"
|
||||
class="float-right mx-2 px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200">
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="article" id="article-upload-field">
|
||||
|
||||
Reference in New Issue
Block a user