diff --git a/webseite/config/subjects/englisch/properties.json b/webseite/config/subjects/englisch/properties.json
index dbf37d3..132c2cc 100644
--- a/webseite/config/subjects/englisch/properties.json
+++ b/webseite/config/subjects/englisch/properties.json
@@ -1,6 +1,6 @@
{
"displayName": "Englisch",
"description": "He she it das s muss mit!",
- "color": "#17B750",
+ "color": "#17b750",
"icon": "fa-language"
}
\ No newline at end of file
diff --git a/webseite/config/subjects/physik/properties.json b/webseite/config/subjects/physik/properties.json
deleted file mode 100644
index 8f3b5c2..0000000
--- a/webseite/config/subjects/physik/properties.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "displayName": "Physik",
- "description": "Noch ein Fach",
- "color": "#363cfc",
- "icon": "fa-square-root-alt"
-}
\ No newline at end of file
diff --git a/webseite/subjectEditor.php b/webseite/subjectEditor.php
index c02230c..4444838 100644
--- a/webseite/subjectEditor.php
+++ b/webseite/subjectEditor.php
@@ -50,6 +50,10 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
$errors["icon"] = "Bitte geben Sie ein Icon an.";
}
+ if(!isset($_POST['submit']) || !($_POST['submit'] == "Speichern" || $_POST['submit'] == "Fach löschen")) {
+ $errors["submit"] = "Ungültig abgeschickt!";
+ }
+
if(empty($errors)) {
$newSubject = false;
if(isset($allSubjects[$_POST['id']])) {
@@ -65,11 +69,15 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
if(!$newSubject) {
$errors["error"] = "Fehler beim Speichern des Faches.";
} else {
- $newSubject->save();
- header("Location: " . "subject.php?subject=" . $newSubject->getId());
+ if($_POST['submit'] == "Fach löschen") {
+ $newSubject->delete();
+ header("Location: " . "index.php");
+ } else {
+ $newSubject->save();
+ header("Location: " . "subject.php?subject=" . $newSubject->getId());
+ }
}
}
-
}
?>
@@ -184,16 +192,13 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
-
-
-
-
+
+
+
+
diff --git a/webseite/topicEditor.php b/webseite/topicEditor.php
index 50a4062..f3cb954 100644
--- a/webseite/topicEditor.php
+++ b/webseite/topicEditor.php
@@ -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') {
-